add -Z flag for AddValidation pass

This commit is contained in:
Ralf Jung 2017-07-21 23:18:34 -07:00
parent e869cf2be7
commit 23cd90ed41
3 changed files with 12 additions and 0 deletions

View File

@ -1025,6 +1025,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"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],

View File

@ -85,6 +85,10 @@ impl MirPass for AddValidation {
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.

View File

@ -77,6 +77,12 @@ impl<'a, 'tcx> MutVisitor<'tcx> for EraseRegionsVisitor<'a, 'tcx> {
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,