Skip to main content

MirProgram

Struct MirProgram 

Source
pub struct MirProgram {
    pub fns: HashMap<FnId, MirFn>,
    pub modules: Vec<ModuleId>,
    pub stats: LowerStats,
    pub builtins: Vec<String>,
    pub external_callers_possible: bool,
}
Expand description

A whole compiled program in Core MIR. Keyed by FnId (stable across compilation units; same identity layer the rest of the pipeline consumes). Phase 2a builds an empty MirProgram directly; Phase 3 grows the lowering that populates it from ResolvedProgramView.

Fields§

§fns: HashMap<FnId, MirFn>

All compiled functions, keyed by their FnId.

§modules: Vec<ModuleId>

Optional module identity for tooling that wants to walk MirProgram per source module (LSP outline, future per-module IR dump). Empty when the program was assembled from a single entry file with no depends [...].

§stats: LowerStats

Coverage telemetry for the lowering that produced this program. lowered + skipped.values().sum() equals the number of ResolvedFnDef items the lowerer saw — see super::stats::LowerStats for the coverage gate that Phase 4 (VM slice) consumes.

§builtins: Vec<String>

Phase 6 wave 11 — interned built-in fn names. Indexed by BuiltinId. Lowering grows this lazily as it encounters each unique ResolvedCallee::Builtin(name) shape; MIR consumers (VM walker, Rust walker, optimize passes) look up the canonical string via program.builtin_name(id) instead of carrying the string inline on every MirCallee::Builtin.

§external_callers_possible: bool

true when this program is a fragment of a larger build whose other parts are compiled separately — specifically a dependency module under the VM’s per-module compile (the VM lowers each depends [...] module to its own MirProgram). Such a fragment does NOT see the entry/sibling call sites, so whole-program analyses that rely on “every caller is visible” (notably own_param_refine) must bail. false for a whole-program compile (single entry, or the flattened wasm-gc / Rust builds), where all callers are present and graduation is sound.

Implementations§

Source§

impl MirProgram

Source

pub fn empty() -> Self

Construct an empty program. Phase 3 lowering will populate fns and modules as it walks ResolvedProgramView.

Source

pub fn fn_by_id(&self, id: FnId) -> Option<&MirFn>

Lookup a function by its FnId. Returns None if the id wasn’t part of this compilation (e.g. a stale id surviving from a previous program view).

Source

pub fn iter(&self) -> impl Iterator<Item = (&FnId, &MirFn)>

All functions in arbitrary (HashMap) order. Callers that need a stable walk (snapshot tests, dump output) should sort by FnId themselves.

Source

pub fn builtin_name(&self, id: BuiltinId) -> &str

Phase 6 wave 11 — look up the canonical name behind a BuiltinId minted by this program’s lowering. Returns "" (empty slice) if the id is out of range — a defensive fallback for diagnostic paths; consumers in the hot path should hold valid ids by construction.

Source

pub fn intern_builtin(&mut self, name: &str) -> BuiltinId

Phase 6 wave 11 — intern a built-in fn name into this program’s table. Returns the stable BuiltinId, reusing the existing slot when the name has already been registered. Lowering calls this; downstream optimizer passes inherit the existing ids when they construct new MirCallee::Builtin instances (e.g. from inlining).

Trait Implementations§

Source§

impl Clone for MirProgram

Source§

fn clone(&self) -> MirProgram

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 Debug for MirProgram

Source§

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

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

impl Default for MirProgram

Source§

fn default() -> MirProgram

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

impl Display for MirProgram

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V