@@ -26,7 +26,7 @@ use syntax::attr;
26
26
27
27
28
28
pub use rustc_mir:: interpret:: * ;
29
- pub use rustc_mir:: interpret:: { self , AllocMap } ; // resolve ambiguity
29
+ pub use rustc_mir:: interpret:: { self , AllocMap , PlaceTy } ; // resolve ambiguity
30
30
31
31
mod fn_call;
32
32
mod operator;
@@ -48,7 +48,16 @@ use crate::mono_hash_map::MonoHashMap;
48
48
use crate :: stacked_borrows:: { EvalContextExt as StackedBorEvalContextExt } ;
49
49
50
50
// Used by priroda
51
- pub use stacked_borrows:: { Borrow , Stacks , Mut as MutBorrow } ;
51
+ pub use crate :: stacked_borrows:: { Borrow , Stack , Stacks , Mut as MutBorrow , BorStackItem } ;
52
+
53
+ /// Insert rustc arguments at the beginning of the argument list that miri wants to be
54
+ /// set per default, for maximal validation power.
55
+ pub fn miri_default_args ( ) -> & ' static [ & ' static str ] {
56
+ // The flags here should be kept in sync with what bootstrap adds when `test-miri` is
57
+ // set, which happens in `bootstrap/bin/rustc.rs` in the rustc sources; and also
58
+ // kept in sync with `xargo/build.sh` in this repo and `appveyor.yml`.
59
+ & [ "-Zalways-encode-mir" , "-Zmir-emit-retag" , "-Zmir-opt-level=0" ]
60
+ }
52
61
53
62
// Used by priroda
54
63
pub fn create_ecx < ' a , ' mir : ' a , ' tcx : ' mir > (
@@ -438,21 +447,30 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
438
447
}
439
448
440
449
#[ inline( always) ]
441
- fn memory_accessed (
450
+ fn memory_read (
442
451
alloc : & Allocation < Borrow , Self :: AllocExtra > ,
443
452
ptr : Pointer < Borrow > ,
444
453
size : Size ,
445
- access : MemoryAccess ,
446
454
) -> EvalResult < ' tcx > {
447
- alloc. extra . memory_accessed ( ptr, size, access)
455
+ alloc. extra . memory_read ( ptr, size)
456
+ }
457
+
458
+ #[ inline( always) ]
459
+ fn memory_written (
460
+ alloc : & mut Allocation < Borrow , Self :: AllocExtra > ,
461
+ ptr : Pointer < Borrow > ,
462
+ size : Size ,
463
+ ) -> EvalResult < ' tcx > {
464
+ alloc. extra . memory_written ( ptr, size)
448
465
}
449
466
450
467
#[ inline( always) ]
451
468
fn memory_deallocated (
452
469
alloc : & mut Allocation < Borrow , Self :: AllocExtra > ,
453
470
ptr : Pointer < Borrow > ,
471
+ size : Size ,
454
472
) -> EvalResult < ' tcx > {
455
- alloc. extra . memory_deallocated ( ptr)
473
+ alloc. extra . memory_deallocated ( ptr, size )
456
474
}
457
475
458
476
#[ inline( always) ]
@@ -507,4 +525,20 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
507
525
Ok ( Pointer :: new_with_tag ( ptr. alloc_id , ptr. offset , tag) )
508
526
}
509
527
}
528
+
529
+ #[ inline( always) ]
530
+ fn retag (
531
+ ecx : & mut EvalContext < ' a , ' mir , ' tcx , Self > ,
532
+ fn_entry : bool ,
533
+ place : PlaceTy < ' tcx , Borrow > ,
534
+ ) -> EvalResult < ' tcx > {
535
+ if !ecx. tcx . sess . opts . debugging_opts . mir_emit_retag || !Self :: enforce_validity ( ecx) {
536
+ // No tracking, or no retagging. This is possible because a dependency of ours might be
537
+ // called with different flags than we are,
538
+ // Also, honor the whitelist in `enforce_validity` because otherwise we might retag
539
+ // uninitialized data.
540
+ return Ok ( ( ) )
541
+ }
542
+ ecx. retag ( fn_entry, place)
543
+ }
510
544
}
0 commit comments