This pass adds validation calls (AcquireValid, ReleaseValid) where appropriate.
It has to be run really early, before transformations like inlining, because
introducing these calls adds UB – so, conceptually, this pass is actually part
of MIR building, and only after this pass we think of the program has having the
normal MIR semantics.
This module provides a pass that removes parts of MIR that are no longer relevant after
analysis phase and borrowck. In particular, it removes false edges, user type annotations and
replaces following statements with
Nop
s:
Finds locals which are assigned once to a const and unused except for debuginfo and converts
their debuginfo to use the const directly, allowing the local to be removed.
This is the implementation of the pass which transforms coroutines into state machines.
A pass that inserts the ConstEvalCounter
instruction into any blocks that have a back edge
(thus indicating there is a loop in the CFG), or whose terminator is a function call.
A constant propagation optimization pass based on dataflow analysis.
This module implements a dead store elimination (DSE) routine.
Deduces supplementary parameter attributes from MIR.
This pass finds basic blocks that are completely equal,
and replaces all uses with just one of them.
Propagates assignment destinations backwards in the CFG to eliminate redundant assignments.
This pass just dumps MIR at a specified point.
This pass transforms derefs of Box into a deref of the pointer inside Box.
Global value numbering.
Inlining pass for MIR functions
Performs various peephole optimizations.
A jump threading optimization.
A lint that checks for known panics like
overflows, division by zero,
out-of-bound access etc.
Uses const propagation to determine the
values of operands during checks.
This pass statically detects code which has undefined behaviour or is likely to be erroneous.
It can be used to locate problems in MIR building or optimizations. It assumes that all code
can be executed, so it has false positives.
Lowers intrinsic calls
This pass lowers calls to core::slice::len to just Len op.
It should run before inlining!
This pass removes jumps to basic blocks containing only a return, and replaces them with a
return instead.
This pass eliminates casting of arrays into slices when their length
is taken using .len()
method. Handy to preserve information in MIR for const prop
These two passes provide no value to the compiler, so are off at every level.
A pass that promotes borrows of constant rvalues.
This pass removes PlaceMention
statement, which has no effect at codegen.
This pass removes storage markers if they won’t be emitted during codegen.
This pass replaces a drop of a type that does not need dropping, with a goto.
Removes operations on ZST places, and convert ZST operands to constants.
Normalizes MIR in RevealAll mode.
A number of passes which remove various redundancies in the CFG.
We denote as “SSA” the set of locals that verify the following properties:
1/ They are only assigned-to once, either as a function parameter, or in an assign statement;
2/ This single assignment dominates all uses;
A pass that eliminates branches on uninhabited enum variants.
A pass that propagates the unreachable terminator of a block to its predecessors
when all of their successors are unreachable. This is achieved through a
post-order traversal of the blocks.
Make MIR ready for const evaluation. This is run on all MIR, not just on consts!
FIXME(oli-obk): it’s unclear whether we still need this phase (and its corresponding query).
We used to have this for pre-miri MIR based const eval.
Obtain just the main MIR (no promoteds) and run some cleanups on it. This also runs
mir borrowck before doing so in order to ensure that borrowck can be run and doesn’t
end up missing the source MIR due to stealing happening.
Compute the MIR that is used during CTFE (and thus has no optimizations run on it)
Finds the full set of DefId
s within the current crate that have
MIR associated with them.
Compute the main MIR body and the list of MIR bodies of the promoteds.
Optimize the MIR and prepare it for codegen.
Fetch all the promoteds of an item and prepare their MIR bodies to be ready for
constant evaluation once all generic parameters become known.
After this series of passes, no lifetime analysis based on borrowing can be done.
Returns the sequence of passes that do the initial cleanup of runtime MIR.
Returns the sequence of passes that lowers analysis to runtime MIR.