@@ -26,7 +26,7 @@ use syntax::attr;
2626
2727
2828pub 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
3030
3131mod fn_call;
3232mod operator;
@@ -48,7 +48,16 @@ use crate::mono_hash_map::MonoHashMap;
4848use crate :: stacked_borrows:: { EvalContextExt as StackedBorEvalContextExt } ;
4949
5050// 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+ }
5261
5362// Used by priroda
5463pub fn create_ecx < ' a , ' mir : ' a , ' tcx : ' mir > (
@@ -438,21 +447,30 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
438447 }
439448
440449 #[ inline( always) ]
441- fn memory_accessed (
450+ fn memory_read (
442451 alloc : & Allocation < Borrow , Self :: AllocExtra > ,
443452 ptr : Pointer < Borrow > ,
444453 size : Size ,
445- access : MemoryAccess ,
446454 ) -> 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)
448465 }
449466
450467 #[ inline( always) ]
451468 fn memory_deallocated (
452469 alloc : & mut Allocation < Borrow , Self :: AllocExtra > ,
453470 ptr : Pointer < Borrow > ,
471+ size : Size ,
454472 ) -> EvalResult < ' tcx > {
455- alloc. extra . memory_deallocated ( ptr)
473+ alloc. extra . memory_deallocated ( ptr, size )
456474 }
457475
458476 #[ inline( always) ]
@@ -507,4 +525,20 @@ impl<'a, 'mir, 'tcx> Machine<'a, 'mir, 'tcx> for Evaluator<'tcx> {
507525 Ok ( Pointer :: new_with_tag ( ptr. alloc_id , ptr. offset , tag) )
508526 }
509527 }
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+ }
510544}
0 commit comments