Skip to main content

Crate rustc_mir_transform

Crate rustc_mir_transform 

Source

Re-exportsΒ§

pub(crate) use required_consts::RequiredConstsVisitor; πŸ”’
pub(crate) use pass_manager as pm; πŸ”’
pub(crate) use pass_manager::Lint; πŸ”’
pub(crate) use pass_manager::MirLint; πŸ”’
pub(crate) use pass_manager::MirPass; πŸ”’
pub(crate) use pass_manager::PassCtx; πŸ”’
pub(crate) use pass_manager::PassPolicy; πŸ”’
pub(crate) use pass_manager::WithMinOptLevel; πŸ”’
pub use shim::build_drop_shim;
pub(crate) use abort_unwinding_calls::AbortUnwindingCalls as _; πŸ”’
pub(crate) use add_call_guards::AddCallGuards as _; πŸ”’
pub(crate) use add_moves_for_packed_drops::AddMovesForPackedDrops as _; πŸ”’
pub(crate) use add_subtyping_projections::Subtyper as _; πŸ”’
pub(crate) use check_inline::CheckForceInline as _; πŸ”’
pub(crate) use check_call_recursion::CheckCallRecursion as _; πŸ”’
pub(crate) use check_call_recursion::CheckDropRecursion as _; πŸ”’
pub(crate) use check_alignment::CheckAlignment as _; πŸ”’
pub(crate) use check_enums::CheckEnums as _; πŸ”’
pub(crate) use check_const_item_mutation::CheckConstItemMutation as _; πŸ”’
pub(crate) use check_null::CheckNull as _; πŸ”’
pub(crate) use check_packed_ref::CheckPackedRef as _; πŸ”’
pub(crate) use check_mut_restriction::CheckMutRestriction as _; πŸ”’
pub(crate) use cleanup_post_borrowck::CleanupPostBorrowck as _; πŸ”’
pub(crate) use copy_prop::CopyProp as _; πŸ”’
pub(crate) use coroutine::StateTransform as _; πŸ”’
pub(crate) use coverage::InstrumentCoverage as _; πŸ”’
pub(crate) use ctfe_limit::CtfeLimit as _; πŸ”’
pub(crate) use dataflow_const_prop::DataflowConstProp as _; πŸ”’
pub(crate) use dead_store_elimination::DeadStoreElimination as _; πŸ”’
pub(crate) use deref_separator::Derefer as _; πŸ”’
pub(crate) use dest_prop::DestinationPropagation as _; πŸ”’
pub(crate) use early_otherwise_branch::EarlyOtherwiseBranch as _; πŸ”’
pub(crate) use erase_deref_temps::EraseDerefTemps as _; πŸ”’
pub(crate) use elaborate_box_derefs::ElaborateBoxDerefs as _; πŸ”’
pub(crate) use elaborate_drops::ElaborateDrops as _; πŸ”’
pub(crate) use function_item_references::FunctionItemReferences as _; πŸ”’
pub(crate) use gvn::GVN as _; πŸ”’
pub(crate) use inline::Inline as _; πŸ”’
pub(crate) use inline::ForceInline as _; πŸ”’
pub(crate) use impossible_clauses::ImpossibleClauses as _; πŸ”’
pub(crate) use instsimplify::InstSimplify as _; πŸ”’
pub(crate) use jump_threading::JumpThreading as _; πŸ”’
pub(crate) use known_panics_lint::KnownPanicsLint as _; πŸ”’
pub(crate) use lint_and_remove_uninhabited::LintAndRemoveUninhabited as _; πŸ”’
pub(crate) use lower_intrinsics::LowerIntrinsics as _; πŸ”’
pub(crate) use lower_slice_len::LowerSliceLenCalls as _; πŸ”’
pub(crate) use match_branches::MatchBranchSimplification as _; πŸ”’
pub(crate) use mentioned_items::MentionedItems as _; πŸ”’
pub(crate) use move_elimination::MoveElimination as _; πŸ”’
pub(crate) use multiple_return_terminators::MultipleReturnTerminators as _; πŸ”’
pub(crate) use post_drop_elaboration::CheckLiveDrops as _; πŸ”’
pub(crate) use prettify::ReorderBasicBlocks as _; πŸ”’
pub(crate) use prettify::ReorderLocals as _; πŸ”’
pub(crate) use promote_consts::PromoteTemps as _; πŸ”’
pub(crate) use ref_prop::ReferencePropagation as _; πŸ”’
pub(crate) use remove_noop_landing_pads::RemoveNoopLandingPads as _; πŸ”’
pub(crate) use remove_place_mention::RemovePlaceMention as _; πŸ”’
pub(crate) use remove_storage_markers::RemoveStorageMarkers as _; πŸ”’
pub(crate) use remove_uninit_drops::RemoveUninitDrops as _; πŸ”’
pub(crate) use remove_unneeded_drops::RemoveUnneededDrops as _; πŸ”’
pub(crate) use remove_zsts::RemoveZsts as _; πŸ”’
pub(crate) use required_consts::RequiredConstsVisitor as _; πŸ”’
pub(crate) use post_analysis_normalize::PostAnalysisNormalize as _; πŸ”’
pub(crate) use sanity_check::SanityCheck as _; πŸ”’
pub(crate) use simplify::SimplifyCfg as _; πŸ”’
pub(crate) use simplify::SimplifyLocals as _; πŸ”’
pub(crate) use simplify_branches::SimplifyConstCondition as _; πŸ”’
pub(crate) use simplify_comparison_integral::SimplifyComparisonIntegral as _; πŸ”’
pub(crate) use single_use_consts::SingleUseConsts as _; πŸ”’
pub(crate) use sroa::ScalarReplacementOfAggregates as _; πŸ”’
pub(crate) use strip_debuginfo::StripDebugInfo as _; πŸ”’
pub(crate) use ssa_range_prop::SsaRangePropagation as _; πŸ”’
pub(crate) use tail_copy_to_move::TailCopyToMove as _; πŸ”’
pub(crate) use unreachable_enum_branching::UnreachableEnumBranching as _; πŸ”’
pub(crate) use unreachable_prop::UnreachablePropagation as _; πŸ”’
pub(crate) use validate::Validator as _; πŸ”’
pub(crate) use hir::ConstContext; πŸ”’
pub(crate) use check_consts; πŸ”’
pub(crate) use ConstCx; πŸ”’
pub(crate) use rustc_const_eval::util; πŸ”’
pub(crate) use rustc_data_structures::fx::FxIndexSet; πŸ”’
pub(crate) use rustc_data_structures::steal::Steal; πŸ”’
pub(crate) use rustc_hir as hir; πŸ”’
pub(crate) use CtorKind; πŸ”’
pub(crate) use DefKind; πŸ”’
pub(crate) use rustc_hir::def_id::LocalDefId; πŸ”’
pub(crate) use rustc_index::IndexVec; πŸ”’
pub(crate) use AnalysisPhase; πŸ”’
pub(crate) use Body; πŸ”’
pub(crate) use CallSource; πŸ”’
pub(crate) use ClearCrossCrate; πŸ”’
pub(crate) use ConstOperand; πŸ”’
pub(crate) use ConstQualifs; πŸ”’
pub(crate) use LocalDecl; πŸ”’
pub(crate) use MirPhase; πŸ”’
pub(crate) use Operand; πŸ”’
pub(crate) use Place; πŸ”’
pub(crate) use ProjectionElem; πŸ”’
pub(crate) use Promoted; πŸ”’
pub(crate) use RuntimePhase; πŸ”’
pub(crate) use Rvalue; πŸ”’
pub(crate) use START_BLOCK; πŸ”’
pub(crate) use SourceInfo; πŸ”’
pub(crate) use Statement; πŸ”’
pub(crate) use StatementKind; πŸ”’
pub(crate) use TerminatorKind; πŸ”’
pub(crate) use WithRetag; πŸ”’
pub(crate) use rustc_middle::query; πŸ”’
pub(crate) use ty; πŸ”’
pub(crate) use TyCtxt; πŸ”’
pub(crate) use TypeVisitableExt; πŸ”’
pub(crate) use rustc_middle::util::Providers; πŸ”’
pub(crate) use DUMMY_SP; πŸ”’
pub(crate) use Spanned; πŸ”’
pub(crate) use bug; πŸ”’
pub(crate) use span_bug; πŸ”’
pub(crate) use sym; πŸ”’
pub(crate) use tracing::debug; πŸ”’
pub(crate) use std::sync::LazyLock; πŸ”’

ModulesΒ§

abort_unwinding_calls πŸ”’
add_call_guards πŸ”’
Breaks outgoing critical edges for call terminators in the MIR.
add_moves_for_packed_drops πŸ”’
add_subtyping_projections πŸ”’
canonicalization πŸ”’
check_alignment πŸ”’
check_call_recursion πŸ”’
check_const_item_mutation πŸ”’
check_enums πŸ”’
check_inline πŸ”’
Check that a body annotated with #[rustc_force_inline] will not fail to inline based on its definition alone (irrespective of any specific caller).
check_mut_restriction πŸ”’
check_null πŸ”’
check_packed_ref πŸ”’
check_pointers πŸ”’
cleanup_post_borrowck
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 Nops:
copy_prop πŸ”’
coroutine πŸ”’
This is the implementation of the pass which transforms coroutines into state machines.
cost_checker πŸ”’
coverage πŸ”’
cross_crate_inline πŸ”’
ctfe_limit πŸ”’
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.
dataflow_const_prop πŸ”’
A constant propagation optimization pass based on dataflow analysis.
dead_store_elimination πŸ”’
This module implements a dead store elimination (DSE) routine.
deduce_param_attrs πŸ”’
Deduces supplementary parameter attributes from MIR.
deref_separator πŸ”’
dest_prop πŸ”’
Propagates assignment destinations backwards in the CFG to eliminate redundant assignments.
diagnostics πŸ”’
early_otherwise_branch πŸ”’
elaborate_box_derefs πŸ”’
This pass transforms derefs of Box into a deref of the pointer inside Box.
elaborate_drop πŸ”’
elaborate_drops πŸ”’
erase_deref_temps πŸ”’
This pass converts all DerefTemp locals into normal temporaries and turns their CopyForDeref rvalues into normal copies.
ffi_unwind_calls πŸ”’
function_item_references πŸ”’
gvn πŸ”’
Global value numbering.
impossible_clauses πŸ”’
Check if it’s even possible to satisfy the β€˜where’ clauses for this item.
inline
Inlining pass for MIR functions.
instsimplify πŸ”’
Performs various peephole optimizations.
jump_threading πŸ”’
A jump threading optimization.
known_panics_lint πŸ”’
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.
lint πŸ”’
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.
lint_and_remove_uninhabited πŸ”’
lint_tail_expr_drop_order πŸ”’
liveness πŸ”’
lower_intrinsics πŸ”’
Lowers intrinsic calls
lower_slice_len πŸ”’
This pass lowers calls to core::slice::len to just PtrMetadata op. It should run before inlining!
match_branches πŸ”’
mentioned_items πŸ”’
move_elimination πŸ”’
Eliminates copies and moves by unifying MIR places whose allocation ranges are disjoint.
multiple_return_terminators πŸ”’
This pass removes jumps to basic blocks containing only a return, and replaces them with a return instead.
pass_manager πŸ”’
patch πŸ”’
post_analysis_normalize πŸ”’
Normalizes MIR in TypingMode::PostAnalysis mode, most notably revealing its opaques. We also only normalize specializable associated items once in PostAnalysis mode.
post_drop_elaboration πŸ”’
prettify πŸ”’
These two passes provide no value to the compiler, so are off at every level.
promote_consts πŸ”’
A pass that promotes borrows of constant rvalues.
ref_prop πŸ”’
remove_noop_landing_pads πŸ”’
remove_place_mention πŸ”’
This pass removes PlaceMention statement, which has no effect at codegen.
remove_storage_markers πŸ”’
This pass removes storage markers if they won’t be emitted during codegen.
remove_uninit_drops πŸ”’
remove_unneeded_drops πŸ”’
This pass replaces a drop of a type that does not need dropping, with a goto.
remove_zsts πŸ”’
Removes operations on ZST places, and convert ZST operands to constants.
required_consts πŸ”’
sanity_check πŸ”’
shim πŸ”’
simplify
A number of passes which remove various redundancies in the CFG.
simplify_branches πŸ”’
simplify_comparison_integral πŸ”’
single_use_consts πŸ”’
sroa πŸ”’
ssa πŸ”’
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;
ssa_range_prop πŸ”’
A pass that propagates the known ranges of SSA locals. We can know the ranges of SSA locals in certain locations for the following code:
strip_debuginfo πŸ”’
tail_copy_to_move πŸ”’
Rewrite final-use copies before return into moves.
trivial_const πŸ”’
unreachable_enum_branching πŸ”’
A pass that eliminates branches on uninhabited or unreachable enum variants.
unreachable_prop πŸ”’
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.
validate πŸ”’
Validates the MIR to ensure that invariants are upheld.

MacrosΒ§

declare_passes πŸ”’
We import passes via this macro so that we can have a static list of pass names (used to verify CLI arguments). It takes a list of modules, followed by the passes declared within them.
pass_names πŸ”’

StaticsΒ§

PASS_NAMES πŸ”’

FunctionsΒ§

inner_mir_for_ctfe πŸ”’
inner_optimized_mir πŸ”’
is_mir_available πŸ”’
mir_built πŸ”’
Implementation of the mir_built query.
mir_const_qualif πŸ”’
mir_drops_elaborated_and_const_checked πŸ”’
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.
mir_for_ctfe πŸ”’
Compute the MIR that is used during CTFE (and thus has no optimizations run on it)
mir_keys πŸ”’
Finds the full set of DefIds within the current crate that have MIR associated with them.
mir_promoted πŸ”’
Compute the main MIR body and the list of MIR bodies of the promoteds.
optimized_mir πŸ”’
Optimize the MIR and prepare it for codegen.
promoted_mir πŸ”’
Fetch all the promoteds of an item and prepare their MIR bodies to be ready for constant evaluation once all generic parameters become known.
provide
remap_mir_for_const_eval_select πŸ”’
run_analysis_cleanup_passes πŸ”’
After this series of passes, no lifetime analysis based on borrowing can be done.
run_analysis_to_runtime_passes
run_optimization_passes πŸ”’
run_runtime_cleanup_passes πŸ”’
Returns the sequence of passes that do the initial cleanup of runtime MIR.
run_runtime_lowering_passes πŸ”’
Returns the sequence of passes that lowers analysis to runtime MIR.
take_array πŸ”’