]> git.lizzy.rs Git - rust.git/commitdiff
add -Z flag for AddValidation pass
authorRalf Jung <post@ralfj.de>
Sat, 22 Jul 2017 06:18:34 +0000 (23:18 -0700)
committerRalf Jung <post@ralfj.de>
Sun, 30 Jul 2017 08:11:59 +0000 (01:11 -0700)
src/librustc/session/config.rs
src/librustc_mir/transform/add_validation.rs
src/librustc_mir/transform/erase_regions.rs

index 8b55eb4c099ae1927e36246be02e1fa6349e11ac..c5ddcb597cbbee059b6b96edf3859d370911e06d 100644 (file)
@@ -1025,6 +1025,8 @@ fn parse_optimization_fuel(slot: &mut Option<(String, u64)>, v: Option<&str>) ->
           "the directory the MIR is dumped into"),
     dump_mir_exclude_pass_number: bool = (false, parse_bool, [UNTRACKED],
           "if set, exclude the pass number when dumping MIR (used in tests)"),
+    mir_emit_validate: bool = (false, parse_bool, [TRACKED],
+          "emit Validate MIR statements, interpreted e.g. by miri"),
     perf_stats: bool = (false, parse_bool, [UNTRACKED],
           "print some performance-related statistics"),
     hir_stats: bool = (false, parse_bool, [UNTRACKED],
index 005d793cd8b537eb5c2c83b72dea2d2eda035626..e400683e8b4e1eef96cdf2aea05e5ee808773baf 100644 (file)
@@ -85,6 +85,10 @@ fn run_pass<'a, 'tcx>(&self,
                           tcx: TyCtxt<'a, 'tcx, 'tcx>,
                           _: MirSource,
                           mir: &mut Mir<'tcx>) {
+        if !tcx.sess.opts.debugging_opts.mir_emit_validate {
+            return;
+        }
+
         let local_decls = mir.local_decls.clone(); // TODO: Find a way to get rid of this clone.
 
         /// Convert an lvalue to a validation operand.
index 12b1c549ffec582cd41a9eb8002f0a52d88a4436..05376ff3d52692487bffa0f2fc9a9c04d7a17517 100644 (file)
@@ -77,6 +77,12 @@ fn visit_statement(&mut self,
                        block: BasicBlock,
                        statement: &mut Statement<'tcx>,
                        location: Location) {
+        if !self.tcx.sess.opts.debugging_opts.mir_emit_validate {
+            if let StatementKind::EndRegion(_) = statement.kind {
+                statement.kind = StatementKind::Nop;
+            }
+        }
+
         self.in_validation_statement = match statement.kind {
             StatementKind::Validate(..) => true,
             _ => false,