Add pass to identify undefined or erroneous behaviour
This commit is contained in:
parent
920e0051cf
commit
7a246ddd8e
7 changed files with 95 additions and 49 deletions
|
@ -2,7 +2,7 @@ use rustc_middle::mir::{self, Body, MirPhase, RuntimePhase};
|
|||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
|
||||
use crate::{validate, MirPass};
|
||||
use crate::{lint::lint_body, validate, MirPass};
|
||||
|
||||
/// Just like `MirPass`, except it cannot mutate `Body`.
|
||||
pub trait MirLint<'tcx> {
|
||||
|
@ -109,6 +109,7 @@ fn run_passes_inner<'tcx>(
|
|||
phase_change: Option<MirPhase>,
|
||||
validate_each: bool,
|
||||
) {
|
||||
let lint = tcx.sess.opts.unstable_opts.lint_mir & !body.should_skip();
|
||||
let validate = validate_each & tcx.sess.opts.unstable_opts.validate_mir & !body.should_skip();
|
||||
let overridden_passes = &tcx.sess.opts.unstable_opts.mir_enable_passes;
|
||||
trace!(?overridden_passes);
|
||||
|
@ -131,6 +132,9 @@ fn run_passes_inner<'tcx>(
|
|||
if validate {
|
||||
validate_body(tcx, body, format!("before pass {name}"));
|
||||
}
|
||||
if lint {
|
||||
lint_body(tcx, body, format!("before pass {name}"));
|
||||
}
|
||||
|
||||
if let Some(prof_arg) = &prof_arg {
|
||||
tcx.sess
|
||||
|
@ -147,6 +151,9 @@ fn run_passes_inner<'tcx>(
|
|||
if validate {
|
||||
validate_body(tcx, body, format!("after pass {name}"));
|
||||
}
|
||||
if lint {
|
||||
lint_body(tcx, body, format!("after pass {name}"));
|
||||
}
|
||||
|
||||
body.pass_count += 1;
|
||||
}
|
||||
|
@ -164,6 +171,9 @@ fn run_passes_inner<'tcx>(
|
|||
if validate || new_phase == MirPhase::Runtime(RuntimePhase::Optimized) {
|
||||
validate_body(tcx, body, format!("after phase change to {}", new_phase.name()));
|
||||
}
|
||||
if lint {
|
||||
lint_body(tcx, body, format!("after phase change to {}", new_phase.name()));
|
||||
}
|
||||
|
||||
body.pass_count = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue