Simplify pass manager's run_passes
logic
This commit is contained in:
parent
aad14c701e
commit
d56751cc34
1 changed files with 19 additions and 29 deletions
|
@ -99,40 +99,35 @@ fn run_passes_inner<'tcx>(
|
|||
let overridden_passes = &tcx.sess.opts.unstable_opts.mir_enable_passes;
|
||||
trace!(?overridden_passes);
|
||||
|
||||
if validate {
|
||||
validate_body(tcx, body, format!("start of phase transition from {:?}", start_phase));
|
||||
}
|
||||
|
||||
for pass in passes {
|
||||
let name = pass.name();
|
||||
|
||||
if let Some((_, polarity)) = overridden_passes.iter().rev().find(|(s, _)| s == &*name) {
|
||||
trace!(
|
||||
pass = %name,
|
||||
"{} as requested by flag",
|
||||
if *polarity { "Running" } else { "Not running" },
|
||||
);
|
||||
if !polarity {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
if !pass.is_enabled(&tcx.sess) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let dump_enabled = pass.is_mir_dump_enabled();
|
||||
// Gather information about what we should be doing for this pass
|
||||
let overriden =
|
||||
overridden_passes.iter().rev().find(|(s, _)| s == &*name).map(|(_name, polarity)| {
|
||||
trace!(
|
||||
pass = %name,
|
||||
"{} as requested by flag",
|
||||
if *polarity { "Running" } else { "Not running" },
|
||||
);
|
||||
*polarity
|
||||
});
|
||||
let is_enabled = overriden.unwrap_or_else(|| pass.is_enabled(&tcx.sess));
|
||||
let new_phase = pass.phase_change();
|
||||
let dump_enabled = (is_enabled && pass.is_mir_dump_enabled()) || new_phase.is_some();
|
||||
let validate = (validate && is_enabled)
|
||||
|| new_phase == Some(MirPhase::Runtime(RuntimePhase::Optimized));
|
||||
|
||||
if dump_enabled {
|
||||
dump_mir(tcx, body, start_phase, &name, cnt, false);
|
||||
}
|
||||
|
||||
pass.run_pass(tcx, body);
|
||||
|
||||
if is_enabled {
|
||||
pass.run_pass(tcx, body);
|
||||
}
|
||||
if dump_enabled {
|
||||
dump_mir(tcx, body, start_phase, &name, cnt, true);
|
||||
cnt += 1;
|
||||
}
|
||||
|
||||
if let Some(new_phase) = pass.phase_change() {
|
||||
if body.phase >= new_phase {
|
||||
panic!("Invalid MIR phase transition from {:?} to {:?}", body.phase, new_phase);
|
||||
|
@ -140,15 +135,10 @@ fn run_passes_inner<'tcx>(
|
|||
|
||||
body.phase = new_phase;
|
||||
}
|
||||
|
||||
if validate {
|
||||
validate_body(tcx, body, format!("after pass {}", pass.name()));
|
||||
validate_body(tcx, body, format!("after pass {}", name));
|
||||
}
|
||||
}
|
||||
|
||||
if validate || body.phase == MirPhase::Runtime(RuntimePhase::Optimized) {
|
||||
validate_body(tcx, body, format!("end of phase transition to {:?}", body.phase));
|
||||
}
|
||||
}
|
||||
|
||||
pub fn validate_body<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, when: String) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue