pub(crate) trait MirPass<'tcx> {
// Required method
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);
// Provided methods
fn name(&self) -> &'static str { ... }
fn profiler_name(&self) -> &'static str { ... }
fn is_enabled(&self, _sess: &Session) -> bool { ... }
fn is_mir_dump_enabled(&self) -> bool { ... }
}
Expand description
A streamlined trait that you can implement to create a pass; the
pass will be named after the type, and it will consist of a main
loop that goes over each available MIR and applies run_pass
.
Required Methods§
Provided Methods§
fn name(&self) -> &'static str
fn profiler_name(&self) -> &'static str
Sourcefn is_enabled(&self, _sess: &Session) -> bool
fn is_enabled(&self, _sess: &Session) -> bool
Returns true
if this pass is enabled with the current combination of compiler flags.
fn is_mir_dump_enabled(&self) -> bool
Implementors§
impl MirPass<'_> for UnreachablePropagation
impl<'tcx> MirPass<'tcx> for AddCallGuards
Breaks outgoing critical edges for call terminators in the MIR.
Critical edges are edges that are neither the only edge leaving a block, nor the only edge entering one.
When you want something to happen “along” an edge, you can either do at the end of the predecessor block, or at the start of the successor block. Critical edges have to be broken in order to prevent “edge actions” from affecting other edges. We need this for calls that are codegened to LLVM invoke instructions, because invoke is a block terminator in LLVM so we can’t insert any code to handle the call’s result into the block that performs the call.
This function will break those edges by inserting new blocks along them.
NOTE: Simplify CFG will happily undo most of the work this pass does.
impl<'tcx> MirPass<'tcx> for DeadStoreElimination
impl<'tcx> MirPass<'tcx> for InstSimplify
impl<'tcx> MirPass<'tcx> for SimplifyCfg
impl<'tcx> MirPass<'tcx> for SimplifyLocals
impl<'tcx> MirPass<'tcx> for SimplifyConstCondition
A pass that replaces a branch with a goto when its condition is known.