Struct rustc_middle::mir::Body [−][src]
pub struct Body<'tcx> {Show 15 fields
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
pub phase: MirPhase,
pub source: MirSource<'tcx>,
pub source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
pub generator: Option<Box<GeneratorInfo<'tcx>>>,
pub local_decls: LocalDecls<'tcx>,
pub user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
pub arg_count: usize,
pub spread_arg: Option<Local>,
pub var_debug_info: Vec<VarDebugInfo<'tcx>>,
pub span: Span,
pub required_consts: Vec<Constant<'tcx>>,
pub is_polymorphic: bool,
predecessor_cache: PredecessorCache,
is_cyclic: GraphIsCyclicCache,
}
Expand description
The lowered representation of a single function.
Fields
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>
A list of basic blocks. References to basic block use a newtyped index type BasicBlock
that indexes into this vector.
phase: MirPhase
Records how far through the “desugaring and optimization” process this particular MIR has traversed. This is particularly useful when inlining, since in that context we instantiate the promoted constants and add them to our promoted vector – but those promoted items have already been optimized, whereas ours have not. This field allows us to see the difference and forego optimization on the inlined promoted items.
source: MirSource<'tcx>
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>
A list of source scopes; these are referenced by statements
and used for debuginfo. Indexed by a SourceScope
.
generator: Option<Box<GeneratorInfo<'tcx>>>
local_decls: LocalDecls<'tcx>
Declarations of locals.
The first local is the return value pointer, followed by arg_count
locals for the function arguments, followed by any user-declared
variables and temporaries.
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>
User type annotations.
arg_count: usize
The number of arguments this function takes.
Starting at local 1, arg_count
locals will be provided by the caller
and can be assumed to be initialized.
If this MIR was built for a constant, this will be 0.
spread_arg: Option<Local>
Mark an argument local (which must be a tuple) as getting passed as its individual components at the LLVM level.
This is used for the “rust-call” ABI.
var_debug_info: Vec<VarDebugInfo<'tcx>>
Debug information pertaining to user variables, including captures.
span: Span
A span representing this MIR, for error reporting.
required_consts: Vec<Constant<'tcx>>
Constants that are required to evaluate successfully for this MIR to be well-formed. We hold in this field all the constants we are not able to evaluate yet.
is_polymorphic: bool
Does this body use generic parameters. This is used for the ConstEvaluatable
check.
Note that this does not actually mean that this body is not computable right now.
The repeat count in the following example is polymorphic, but can still be evaluated
without knowing anything about the type parameter T
.
fn test<T>() {
let _ = [0; std::mem::size_of::<*mut T>()];
}
WARNING: Do not change this flags after the MIR was originally created, even if an optimization
removed the last mention of all generic params. We do not want to rely on optimizations and
potentially allow things like [u8; std::mem::size_of::<T>() * 0]
due to this.
predecessor_cache: PredecessorCache
is_cyclic: GraphIsCyclicCache
Implementations
pub fn new(
tcx: TyCtxt<'tcx>,
source: MirSource<'tcx>,
basic_blocks: IndexVec<BasicBlock, BasicBlockData<'tcx>>,
source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>,
local_decls: LocalDecls<'tcx>,
user_type_annotations: CanonicalUserTypeAnnotations<'tcx>,
arg_count: usize,
var_debug_info: Vec<VarDebugInfo<'tcx>>,
span: Span,
generator_kind: Option<GeneratorKind>
) -> Self
Returns a partially initialized MIR body containing only a list of basic blocks.
The returned MIR contains no LocalDecl
s (even for the return place) or source scopes. It
is only useful for testing but cannot be #[cfg(test)]
because it is used in a different
crate.
pub fn basic_blocks_and_local_decls_mut(
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut LocalDecls<'tcx>)
pub fn basic_blocks_local_decls_mut_and_var_debug_info(
&mut self
) -> (&mut IndexVec<BasicBlock, BasicBlockData<'tcx>>, &mut LocalDecls<'tcx>, &mut Vec<VarDebugInfo<'tcx>>)
Returns true
if a cycle exists in the control-flow graph that is reachable from the
START_BLOCK
.
Returns an iterator over all user-declared mutable locals.
Returns an iterator over all user-declared mutable arguments and locals.
Returns an iterator over all function arguments.
pub fn vars_and_temps_iter(
&self
) -> impl DoubleEndedIterator<Item = Local> + ExactSizeIterator
pub fn vars_and_temps_iter(
&self
) -> impl DoubleEndedIterator<Item = Local> + ExactSizeIterator
Returns an iterator over all user-defined variables and compiler-generated temporaries (all locals that are neither arguments nor the return place).
Changes a statement to a nop. This is both faster than deleting instructions and avoids
invalidating statement indices in Location
s.
Returns the source info associated with location
.
Returns the return type; it always return first element from local_decls
array.
Gets the location of the terminator for the given block.
Trait Implementations
fn allocate_from_iter<'a>(
arena: &'a Arena<'tcx>,
iter: impl IntoIterator<Item = Self>
) -> &'a mut [Self]
type Node = BasicBlock
type Item = BasicBlock
type Iter = Copied<Iter<'graph, BasicBlock>>
type Item = BasicBlock
type Iter = Cloned<Successors<'b>>
type Output = BasicBlockData<'tcx>
type Output = BasicBlockData<'tcx>
The returned type after indexing.
Performs the indexing (container[index]
) operation. Read more
Performs the mutable indexing (container[index]
) operation. Read more
fn super_visit_with<__F: TypeVisitor<'tcx>>(
&self,
__folder: &mut __F
) -> ControlFlow<__F::BreakTy>
Returns true
if self
has any late-bound regions that are either
bound by binder
or bound by some binder outside of binder
.
If binder
is ty::INNERMOST
, this indicates whether
there are any late-bound regions that appear free. Read more
Returns true
if this self
has any regions that escape binder
(and
hence are not bound by it). Read more
“Free” regions in this context means that it has any region that is not (a) erased or (b) late-bound. Read more
True if there are any un-erased free regions.
Indicates whether this value definitely references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
Indicates whether this value references only ‘global’ generic parameters that are the same regardless of what fn we are in. This is used for caching. Read more
True if there are any late-bound regions
Indicates whether this value still has parameters/placeholders/inference variables
which could be replaced later, in a way that would change the results of impl
specialization. Read more
fn successors(
&self,
node: Self::Node
) -> Cloned<Chain<IntoIter<&BasicBlock>, Iter<'_, BasicBlock>>>
fn depth_first_search(&self, from: Self::Node) -> DepthFirstSearch<'_, Self> where
Self: WithNumNodes,
Auto Trait Implementations
impl<'tcx> !RefUnwindSafe for Body<'tcx>
impl<'tcx> !UnwindSafe for Body<'tcx>
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
impl<Ctxt, T> DepNodeParams<Ctxt> for T where
Ctxt: DepContext,
T: for<'a> HashStable<StableHashingContext<'a>> + Debug,
This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous). Read more
This method tries to recover the query key from the given DepNode
,
something which is needed when forcing DepNode
s during red-green
evaluation. The query system will only call this method if
fingerprint_style()
is not FingerprintStyle::Opaque
.
It is always valid to return None
here, in which case incremental
compilation will treat the query as having changed instead of forcing it. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 232 bytes