pub(crate) trait MirPass<'tcx> {
// Required methods
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>);
fn is_required(&self) -> bool;
// Provided methods
fn name(&self) -> &'static str { ... }
fn profiler_name(&self) -> &'static str { ... }
fn is_enabled(&self, _sess: &Session) -> bool { ... }
fn can_be_overridden(&self) -> 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§
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>)
Sourcefn is_required(&self) -> bool
fn is_required(&self) -> bool
Returns true
if this pass must be run (i.e. it is required for soundness).
For passes which are strictly optimizations, this should return false
.
If this is false
, #[optimize(none)]
will disable the pass.
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.
Sourcefn can_be_overridden(&self) -> bool
fn can_be_overridden(&self) -> bool
Returns true
if this pass can be overridden by -Zenable-mir-passes
. This should be
true for basically every pass other than those that are necessary for correctness.
fn is_mir_dump_enabled(&self) -> bool
Implementors§
impl MirPass<'_> for UnreachablePropagation
impl<'tcx> MirPass<'tcx> for AddCallGuards
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.