Clarify which kinds of MIR are allowed during which phases.

This enhances documentation with these details and extends the validator to check these requirements
more thoroughly. As a part of this, we add a new `Deaggregated` phase, and rename other phases so
that their names more naturally correspond to what they represent.
This commit is contained in:
Jakob Degen 2022-03-05 20:37:04 -05:00
parent 547369d3d8
commit fe40240e4d
8 changed files with 98 additions and 52 deletions

View file

@ -341,7 +341,7 @@ fn inner_mir_for_ctfe(tcx: TyCtxt<'_>, def: ty::WithOptConstParam<LocalDefId>) -
pm::run_passes(
tcx,
&mut body,
&[&const_prop::ConstProp, &marker::PhaseChange(MirPhase::Optimization)],
&[&const_prop::ConstProp, &marker::PhaseChange(MirPhase::Optimized)],
);
}
}
@ -398,7 +398,7 @@ fn mir_drops_elaborated_and_const_checked<'tcx>(
}
run_post_borrowck_cleanup_passes(tcx, &mut body);
assert!(body.phase == MirPhase::DropLowering);
assert!(body.phase == MirPhase::Deaggregated);
tcx.alloc_steal_mir(body)
}
@ -458,7 +458,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
],
);
assert!(body.phase == MirPhase::GeneratorLowering);
assert!(body.phase == MirPhase::GeneratorsLowered);
// The main optimizations that we do on MIR.
pm::run_passes(
@ -495,7 +495,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
&deduplicate_blocks::DeduplicateBlocks,
// Some cleanup necessary at least for LLVM and potentially other codegen backends.
&add_call_guards::CriticalCallEdges,
&marker::PhaseChange(MirPhase::Optimization),
&marker::PhaseChange(MirPhase::Optimized),
// Dump the end result for testing and debugging purposes.
&dump_mir::Marker("PreCodegen"),
],