flowistry_pdg::rustc::mir

Struct Body

Source
pub struct Body<'tcx> {
Show 19 fields pub basic_blocks: BasicBlocks<'tcx>, pub phase: MirPhase, pub pass_count: usize, pub source: MirSource<'tcx>, pub source_scopes: IndexVec<SourceScope, SourceScopeData<'tcx>>, pub coroutine: Option<Box<CoroutineInfo<'tcx>>>, pub local_decls: IndexVec<Local, LocalDecl<'tcx>>, pub user_type_annotations: IndexVec<UserTypeAnnotationIndex, CanonicalUserTypeAnnotation<'tcx>>, pub arg_count: usize, pub spread_arg: Option<Local>, pub var_debug_info: Vec<VarDebugInfo<'tcx>>, pub span: Span, pub required_consts: Option<Vec<ConstOperand<'tcx>>>, pub mentioned_items: Option<Vec<Spanned<MentionedItem<'tcx>>>>, pub is_polymorphic: bool, pub injection_phase: Option<MirPhase>, pub tainted_by_errors: Option<ErrorGuaranteed>, pub coverage_info_hi: Option<Box<CoverageInfoHi>>, pub function_coverage_info: Option<Box<FunctionCoverageInfo>>,
}
Expand description

The lowered representation of a single function.

Fields§

§basic_blocks: BasicBlocks<'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.

§pass_count: usize

How many passses we have executed since starting the current phase. Used for debug output.

§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.

§coroutine: Option<Box<CoroutineInfo<'tcx>>>

Additional information carried by a MIR body when it is lowered from a coroutine.

Note that the coroutine drop shim, any promoted consts, and other synthetic MIR bodies that come from processing a coroutine body are not typically coroutines themselves, and should probably set this to None to avoid carrying redundant information.

§local_decls: IndexVec<Local, LocalDecl<'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: IndexVec<UserTypeAnnotationIndex, CanonicalUserTypeAnnotation<'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: Option<Vec<ConstOperand<'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. None indicates that the list has not been computed yet.

This is soundness-critical, we make a guarantee that all consts syntactically mentioned in a function have successfully evaluated if the function ever gets executed at runtime.

§mentioned_items: Option<Vec<Spanned<MentionedItem<'tcx>>>>

Further items that were mentioned in this function and hence may become monomorphized, depending on optimizations. We use this to avoid optimization-dependent compile errors: the collector recursively traverses all “mentioned” items and evaluates all their required_consts. None indicates that the list has not been computed yet.

This is not soundness-critical and the contents of this list are not a stable guarantee. All that’s relevant is that this set is optimization-level-independent, and that it includes everything that the collector would consider “used”. (For example, we currently compute this set after drop elaboration, so some drop calls that can never be reached are not considered “mentioned”.) See the documentation of CollectionMode in compiler/rustc_monomorphize/src/collector.rs for more context.

§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.

§injection_phase: Option<MirPhase>

The phase at which this MIR should be “injected” into the compilation process.

Everything that comes before this MirPhase should be skipped.

This is only Some if the function that this body comes from was annotated with rustc_custom_mir.

§tainted_by_errors: Option<ErrorGuaranteed>§coverage_info_hi: Option<Box<CoverageInfoHi>>

Coverage information collected from THIR/MIR during MIR building, to be used by the InstrumentCoverage pass.

Only present if coverage is enabled and this function is eligible. Boxed to limit space overhead in non-coverage builds.

§function_coverage_info: Option<Box<FunctionCoverageInfo>>

Per-function coverage information added by the InstrumentCoverage pass, to be used in conjunction with the coverage statements injected into this body’s blocks.

If -Cinstrument-coverage is not active, or if an individual function is not eligible for coverage, then this should always be None.

Auto Trait Implementations§

§

impl<'tcx> !Freeze for Body<'tcx>

§

impl<'tcx> !RefUnwindSafe for Body<'tcx>

§

impl<'tcx> Send for Body<'tcx>

§

impl<'tcx> Sync for Body<'tcx>

§

impl<'tcx> Unpin for Body<'tcx>

§

impl<'tcx> !UnwindSafe for Body<'tcx>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.