Skip to main content

BasicBlock

Struct BasicBlock 

Source
pub struct BasicBlock<'str> {
    pub params: Vec<LocalParamId>,
    pub instructions: Vec<LocalInsnId>,
    pub edges: HashSet<EdgeId, FxBuildHasher>,
    pub address: Option<u64>,
    pub extra_addresses: Vec<u64>,
    /* private fields */
}
Expand description

A block of instructions. This is the basic unit of code in our IR.

Fields§

§params: Vec<LocalParamId>

Typed parameters declared at block entry (block-argument style). These are NOT part of instructions; use params() to iterate them.

§instructions: Vec<LocalInsnId>

The ids of the instructions in this block

§edges: HashSet<EdgeId, FxBuildHasher>

The set of edges that this block is incident to, as bare body-local EdgeIds (see add_cfg_edge).

Strict IR locality (ruling 2) guarantees every edge incident to a block is stored in that block’s own function arena, so the owning FunctionId is always the block’s own id.func — it is recovered at the point of use rather than stored per edge (stage 6a, mirroring the stage-4 EdgeId strip).

Uses a fixed-seed hasher (matching Context’s Graph::Hasher) so that predecessors()/successors() iterate deterministically across runs.

§address: Option<u64>

The address of this block, if it corresponds to a machine address.

§extra_addresses: Vec<u64>

Additional addresses that map to this block (accumulated from merged blocks).

Implementations§

Source§

impl<'str> BasicBlock<'str>

Source

pub fn instruction_ids(&self) -> &[LocalInsnId]

The ids of the instructions in this block, in order (raw &BasicBlock accessor). Routing target for the raw .instructions field reads (stage 6a §11); the field itself becomes private and localizes behind this accessor at the storage flip.

Source

pub fn param_ids(&self) -> &[LocalParamId]

The ids of this block’s parameters, in declaration order (raw &BasicBlock accessor). Routing target for the raw .params field reads (stage 6a §11).

Source

pub fn from_id<'ctx>( ctx: &'ctx Context<'str>, id: BlockId, ) -> BlockRef<'str, 'ctx>

Gets a reference to a block from its ID

Source

pub fn from_id_mut<'ctx>( ctx: &'ctx mut Context<'str>, id: BlockId, ) -> BlockMutRef<'str, 'ctx>

Gets a mutable reference to a block from its ID

Source

pub fn from_name<'ctx>( ctx: &'ctx Context<'str>, name: &str, ) -> Option<BlockRef<'str, 'ctx>>

Gets a reference to a block by name. Block names are function-scoped, so this scans every function’s local name table and returns the first match (names are unique within a function, not across the program). Prefer FunctionRef::local_named when the owning function is known.

Source

pub fn make<'ctx>( ctx: &'ctx mut Context<'str>, func: FunctionId, ) -> BlockMutRef<'str, 'ctx>

Create a new block, born into func’s block arena. Ownership is derived from arena membership (the storing function).

Source

pub fn clone_block_into( ctx: &mut Context<'str>, orig: BlockId, target: FunctionId, value_map: &mut HashMap<ValueId, ValueId>, ) -> BlockId

Structurally clone the block at orig into a fresh block owned by (and stored in) target, without remapping operands.

This is the storage-move sibling of clone_into_ctx: where clone_into_ctx builds a semantically independent copy inside the same function (used by the tracer), this reproduces orig verbatim in a different function’s arenas — preserving each instruction’s exact result TypeId and machine address, and the block’s own name — so a caller relocating a reattributed block can then fix up the references in a single whole-function pass. It records orig‘s params and instruction results in value_map (old id -> new id) but leaves the new instructions’ operands and block targets pointing at the originals; the caller remaps them once the full map is known (so forward references between relocated blocks resolve).

Source

pub fn clone_into_ctx( ctx: &mut Context<'str>, orig: BlockId, value_map: &mut HashMap<ValueId, ValueId>, ) -> BlockId

Deep-clone the block at orig into a new block in the same context. Updates value_map with parameters and instructions remapping.

Trait Implementations§

Source§

impl<'str> Clone for BasicBlock<'str>

Source§

fn clone(&self) -> BasicBlock<'str>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'str> Debug for BasicBlock<'str>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'str> Default for BasicBlock<'str>

Source§

fn default() -> BasicBlock<'str>

Returns the “default value” for a type. Read more
Source§

impl<'de, 'str> Deserialize<'de> for BasicBlock<'str>

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'str> Serialize for BasicBlock<'str>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<'str> Freeze for BasicBlock<'str>

§

impl<'str> RefUnwindSafe for BasicBlock<'str>

§

impl<'str> Send for BasicBlock<'str>

§

impl<'str> Sync for BasicBlock<'str>

§

impl<'str> Unpin for BasicBlock<'str>

§

impl<'str> UnsafeUnpin for BasicBlock<'str>

§

impl<'str> UnwindSafe for BasicBlock<'str>

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, dest: *mut u8)

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.