Skip to main content Crate rustc_mir_transform Copy item path Source 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 ; π 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 Nop s: 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. 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 π PASS_NAMES π 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 π