@@ -9,12 +9,11 @@ use rustc_ast::expand::allocator::alloc_error_handler_name;
9
9
use rustc_hir:: def:: DefKind ;
10
10
use rustc_hir:: def_id:: CrateNum ;
11
11
use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
12
- use rustc_middle:: { mir, ty} ;
13
12
use rustc_middle:: ty:: Ty ;
13
+ use rustc_middle:: { mir, ty} ;
14
14
use rustc_span:: Symbol ;
15
15
use rustc_target:: callconv:: { Conv , FnAbi } ;
16
16
17
-
18
17
use self :: helpers:: { ToHost , ToSoft } ;
19
18
use super :: alloc:: EvalContextExt as _;
20
19
use super :: backtrace:: EvalContextExt as _;
@@ -279,7 +278,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
279
278
match link_name. as_str ( ) {
280
279
// Miri-specific extern functions
281
280
"miri_start_unwind" => {
282
- let [ payload] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
281
+ let [ payload] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
283
282
this. handle_miri_start_unwind ( payload) ?;
284
283
return interp_ok ( EmulateItemResult :: NeedsUnwind ) ;
285
284
}
@@ -288,7 +287,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
288
287
this. run_provenance_gc ( ) ;
289
288
}
290
289
"miri_get_alloc_id" => {
291
- let [ ptr] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
290
+ let [ ptr] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
292
291
let ptr = this. read_pointer ( ptr) ?;
293
292
let ( alloc_id, _, _) = this. ptr_get_alloc_id ( ptr, 0 ) . map_err_kind ( |_e| {
294
293
err_machine_stop ! ( TerminationInfo :: Abort ( format!(
@@ -298,7 +297,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
298
297
this. write_scalar ( Scalar :: from_u64 ( alloc_id. 0 . get ( ) ) , dest) ?;
299
298
}
300
299
"miri_print_borrow_state" => {
301
- let [ id, show_unnamed] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
300
+ let [ id, show_unnamed] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
302
301
let id = this. read_scalar ( id) ?. to_u64 ( ) ?;
303
302
let show_unnamed = this. read_scalar ( show_unnamed) ?. to_bool ( ) ?;
304
303
if let Some ( id) = std:: num:: NonZero :: new ( id) . map ( AllocId )
@@ -312,8 +311,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
312
311
"miri_pointer_name" => {
313
312
// This associates a name to a tag. Very useful for debugging, and also makes
314
313
// tests more strict.
315
- let [ ptr, nth_parent, name] =
316
- this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
314
+ let [ ptr, nth_parent, name] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
317
315
let ptr = this. read_pointer ( ptr) ?;
318
316
let nth_parent = this. read_scalar ( nth_parent) ?. to_u8 ( ) ?;
319
317
let name = this. read_immediate ( name) ?;
@@ -337,8 +335,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
337
335
this. machine . static_roots . push ( alloc_id) ;
338
336
}
339
337
"miri_host_to_target_path" => {
340
- let [ ptr, out, out_size] =
341
- this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
338
+ let [ ptr, out, out_size] = this. check_shim ( abi, Conv :: Rust , link_name, args) ?;
342
339
let ptr = this. read_pointer ( ptr) ?;
343
340
let out = this. read_pointer ( out) ?;
344
341
let out_size = this. read_scalar ( out_size) ?. to_target_usize ( this) ?;
@@ -429,22 +426,20 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
429
426
430
427
// Aborting the process.
431
428
"exit" => {
432
- let [ code] =
433
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
429
+ let [ code] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
434
430
let code = this. read_scalar ( code) ?. to_i32 ( ) ?;
435
431
throw_machine_stop ! ( TerminationInfo :: Exit { code: code. into( ) , leak_check: false } ) ;
436
432
}
437
433
"abort" => {
438
- let [ ] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
434
+ let [ ] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
439
435
throw_machine_stop ! ( TerminationInfo :: Abort (
440
436
"the program aborted execution" . to_owned( )
441
437
) )
442
438
}
443
439
444
440
// Standard C allocation
445
441
"malloc" => {
446
- let [ size] =
447
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
442
+ let [ size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
448
443
let size = this. read_target_usize ( size) ?;
449
444
if size <= this. max_size_of_val ( ) . bytes ( ) {
450
445
let res = this. malloc ( size, /*zero_init:*/ false ) ?;
@@ -458,8 +453,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
458
453
}
459
454
}
460
455
"calloc" => {
461
- let [ items, elem_size] =
462
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
456
+ let [ items, elem_size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
463
457
let items = this. read_target_usize ( items) ?;
464
458
let elem_size = this. read_target_usize ( elem_size) ?;
465
459
if let Some ( size) = this. compute_size_in_bytes ( Size :: from_bytes ( elem_size) , items) {
@@ -474,14 +468,12 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
474
468
}
475
469
}
476
470
"free" => {
477
- let [ ptr] =
478
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
471
+ let [ ptr] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
479
472
let ptr = this. read_pointer ( ptr) ?;
480
473
this. free ( ptr) ?;
481
474
}
482
475
"realloc" => {
483
- let [ old_ptr, new_size] =
484
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
476
+ let [ old_ptr, new_size] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
485
477
let old_ptr = this. read_pointer ( old_ptr) ?;
486
478
let new_size = this. read_target_usize ( new_size) ?;
487
479
if new_size <= this. max_size_of_val ( ) . bytes ( ) {
@@ -619,8 +611,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
619
611
620
612
// C memory handling functions
621
613
"memcmp" => {
622
- let [ left, right, n] =
623
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
614
+ let [ left, right, n] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
624
615
let left = this. read_pointer ( left) ?;
625
616
let right = this. read_pointer ( right) ?;
626
617
let n = Size :: from_bytes ( this. read_target_usize ( n) ?) ;
@@ -644,8 +635,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
644
635
this. write_scalar ( Scalar :: from_i32 ( result) , dest) ?;
645
636
}
646
637
"memrchr" => {
647
- let [ ptr, val, num] =
648
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
638
+ let [ ptr, val, num] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
649
639
let ptr = this. read_pointer ( ptr) ?;
650
640
let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
651
641
let num = this. read_target_usize ( num) ?;
@@ -671,8 +661,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
671
661
}
672
662
}
673
663
"memchr" => {
674
- let [ ptr, val, num] =
675
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
664
+ let [ ptr, val, num] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
676
665
let ptr = this. read_pointer ( ptr) ?;
677
666
let val = this. read_scalar ( val) ?. to_i32 ( ) ?;
678
667
let num = this. read_target_usize ( num) ?;
@@ -695,8 +684,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
695
684
}
696
685
}
697
686
"strlen" => {
698
- let [ ptr] =
699
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
687
+ let [ ptr] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
700
688
let ptr = this. read_pointer ( ptr) ?;
701
689
// This reads at least 1 byte, so we are already enforcing that this is a valid pointer.
702
690
let n = this. read_c_str ( ptr) ?. len ( ) ;
@@ -706,8 +694,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
706
694
) ?;
707
695
}
708
696
"wcslen" => {
709
- let [ ptr] =
710
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
697
+ let [ ptr] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
711
698
let ptr = this. read_pointer ( ptr) ?;
712
699
// This reads at least 1 byte, so we are already enforcing that this is a valid pointer.
713
700
let n = this. read_wchar_t_str ( ptr) ?. len ( ) ;
@@ -717,8 +704,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
717
704
) ?;
718
705
}
719
706
"memcpy" => {
720
- let [ ptr_dest, ptr_src, n] =
721
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
707
+ let [ ptr_dest, ptr_src, n] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
722
708
let ptr_dest = this. read_pointer ( ptr_dest) ?;
723
709
let ptr_src = this. read_pointer ( ptr_src) ?;
724
710
let n = this. read_target_usize ( n) ?;
@@ -732,8 +718,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
732
718
this. write_pointer ( ptr_dest, dest) ?;
733
719
}
734
720
"strcpy" => {
735
- let [ ptr_dest, ptr_src] =
736
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
721
+ let [ ptr_dest, ptr_src] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
737
722
let ptr_dest = this. read_pointer ( ptr_dest) ?;
738
723
let ptr_src = this. read_pointer ( ptr_src) ?;
739
724
@@ -878,8 +863,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
878
863
this. write_scalar ( res, dest) ?;
879
864
}
880
865
"lgammaf_r" => {
881
- let [ x, signp] =
882
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
866
+ let [ x, signp] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
883
867
let x = this. read_scalar ( x) ?. to_f32 ( ) ?;
884
868
let signp = this. deref_pointer ( signp) ?;
885
869
@@ -890,8 +874,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
890
874
this. write_scalar ( res, dest) ?;
891
875
}
892
876
"lgamma_r" => {
893
- let [ x, signp] =
894
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
877
+ let [ x, signp] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
895
878
let x = this. read_scalar ( x) ?. to_f64 ( ) ?;
896
879
let signp = this. deref_pointer ( signp) ?;
897
880
@@ -904,8 +887,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
904
887
905
888
// LLVM intrinsics
906
889
"llvm.prefetch" => {
907
- let [ p, rw, loc, ty] =
908
- this. check_shim ( abi, Conv :: C , link_name, args) ?;
890
+ let [ p, rw, loc, ty] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
909
891
910
892
let _ = this. read_pointer ( p) ?;
911
893
let rw = this. read_scalar ( rw) ?. to_i32 ( ) ?;
@@ -932,7 +914,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
932
914
// Used to implement the x86 `_mm{,256,512}_popcnt_epi{8,16,32,64}` and wasm
933
915
// `{i,u}8x16_popcnt` functions.
934
916
name if name. starts_with ( "llvm.ctpop.v" ) => {
935
- let [ op] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
917
+ let [ op] = this. check_shim ( abi, Conv :: C , link_name, args) ?;
936
918
937
919
let ( op, op_len) = this. project_to_simd ( op) ?;
938
920
let ( dest, dest_len) = this. project_to_simd ( dest) ?;
0 commit comments