pub struct FunctionCx<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> {
Show 16 fields instance: Instance<'tcx>, mir: &'tcx Body<'tcx>, debug_context: Option<FunctionDebugContext<Bx::DIScope, Bx::DILocation>>, llfn: Bx::Function, cx: &'a Bx::CodegenCx, fn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>, personality_slot: Option<PlaceRef<'tcx, Bx::Value>>, cached_llbbs: IndexVec<BasicBlock, Option<Bx::BasicBlock>>, cleanup_kinds: IndexVec<BasicBlock, CleanupKind>, funclets: IndexVec<BasicBlock, Option<Bx::Funclet>>, landing_pads: IndexVec<BasicBlock, Option<Bx::BasicBlock>>, unreachable_block: Option<Bx::BasicBlock>, double_unwind_guard: Option<Bx::BasicBlock>, locals: IndexVec<Local, LocalRef<'tcx, Bx::Value>>, per_local_var_debug_info: Option<IndexVec<Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>>, caller_location: Option<OperandRef<'tcx, Bx::Value>>,
Expand description

Master context for codegenning from MIR.


instance: Instance<'tcx>mir: &'tcx Body<'tcx>debug_context: Option<FunctionDebugContext<Bx::DIScope, Bx::DILocation>>llfn: Bx::Functioncx: &'a Bx::CodegenCxfn_abi: &'tcx FnAbi<'tcx, Ty<'tcx>>personality_slot: Option<PlaceRef<'tcx, Bx::Value>>

When unwinding is initiated, we have to store this personality value somewhere so that we can load it and re-use it in the resume instruction. The personality is (afaik) some kind of value used for C++ unwinding, which must filter by type: we don’t really care about it very much. Anyway, this value contains an alloca into which the personality is stored and then later loaded when generating the DIVERGE_BLOCK.

cached_llbbs: IndexVec<BasicBlock, Option<Bx::BasicBlock>>

A backend BasicBlock for each MIR BasicBlock, created lazily as-needed (e.g. RPO reaching it or another block branching to it).

cleanup_kinds: IndexVec<BasicBlock, CleanupKind>

The funclet status of each basic block

funclets: IndexVec<BasicBlock, Option<Bx::Funclet>>

When targeting MSVC, this stores the cleanup info for each funclet BB. This is initialized at the same time as the landing_pads entry for the funclets’ head block, i.e. when needed by an unwind / cleanup_ret edge.

landing_pads: IndexVec<BasicBlock, Option<Bx::BasicBlock>>

This stores the cached landing/cleanup pad block for a given BB.

unreachable_block: Option<Bx::BasicBlock>

Cached unreachable block

double_unwind_guard: Option<Bx::BasicBlock>

Cached double unwind guarding block

locals: IndexVec<Local, LocalRef<'tcx, Bx::Value>>

The location where each MIR arg/var/tmp/ret is stored. This is usually an PlaceRef representing an alloca, but not always: sometimes we can skip the alloca and just store the value directly using an OperandRef, which makes for tighter LLVM IR. The conditions for using an OperandRef are as follows:

  • the type of the local must be judged “immediate” by is_llvm_immediate
  • the operand must never be referenced indirectly
    • we should not take its address using the & operator
    • nor should it appear in a place path like tmp.a
  • the operand must be defined by an rvalue that can generate immediate values

Avoiding allocs can also be important for certain intrinsics, notably expect.

per_local_var_debug_info: Option<IndexVec<Local, Vec<PerLocalVarDebugInfo<'tcx, Bx::DIVariable>>>>

All VarDebugInfo from the MIR body, partitioned by Local. This is None if no var#[non_exhaustive]iable debuginfo/names are needed.

caller_location: Option<OperandRef<'tcx, Bx::Value>>

Caller location propagated if this function has #[track_caller].


Codegen implementations for some terminator variants.

Generates code for a Resume terminator.

Returns true if this is indeed a panic intrinsic and codegen is done.

Returns the landing/cleanup pad wrapper around the given basic block.

Get the backend BasicBlock for a MIR BasicBlock, either already cached in self.cached_llbbs, or created on demand (and cached).

process constant containing SIMD shuffle indices

In order to have a good line stepping behavior in debugger, we overwrite debug locations of macro expansions with that of the outermost expansion site (unless the crate is being compiled with -Z debug-macros).

Apply debuginfo and/or name, after creating the alloca for a local, or initializing the local with an operand (whichever applies).

Partition all VarDebugInfo in self.mir, by their base Local.

Codegen an Rvalue::AddressOf or Rvalue::Ref

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.


Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.