Skip to main content

ValueRegistry

Struct ValueRegistry 

Source
pub struct ValueRegistry<'str> {
    pub literals: LiteralInterner,
    pub bytes: Interner<BytesId, Bytes>,
    pub poisons: Interner<PoisonId, Poison>,
    pub varnodes: Registry<VarnodeId, Varnode<'str>>,
    /* private fields */
}
Expand description

Central storage arena for all IR values in a Context.

Each field is a typed arena (Registry) keyed by the corresponding ID type. Values are append-only: once pushed, their ID is stable for the lifetime of the registry and their data is never moved.

§Invariants

  • push_insn is final. Instructions are immutable after insertion. The owning function’s users map is populated at push time from the instruction’s operands and is not updated if operands are later altered via interior mutation. Use Context::replace_all_uses_with to rewrite operands while keeping users consistent.

  • users is managed internally. The reverse use-def map now lives in each FunctionBody (function-scoped; see FunctionBody::users_of). Do not mutate it directly. Read it through FunctionRef::users_of / Context::users, and remove dead instructions via Context::remove_instructions.

Fields§

§literals: LiteralInterner

Literal (constant) interner. Behind an RwLock (see LiteralInterner) so constants can be minted through a shared &; the dedup cache lives inside it.

§bytes: Interner<BytesId, Bytes>

Opaque byte-blob constant interner (constants wider than a u64).

§poisons: Interner<PoisonId, Poison>

Poison-value interner (argpromote v2). Each poison is a distinct interned value (never deduped), so two poisons are never congruent.

§varnodes: Registry<VarnodeId, Varnode<'str>>

Varnode storage.

Implementations§

Source§

impl<'str> ValueRegistry<'str>

Source

pub fn get_or_make_typed_literal( &self, value: u64, type_id: TypeId, size: usize, ) -> LiteralId

Returns a canonical LiteralId for the given typed constant.

The value is masked to type_id’s size before lookup. Symbolic literals (created via push_literal) are not included in the intern cache and will not alias with constants produced here.

Call Context::get_const for the common Int(size) case; use this method directly when you need to preserve a non-Int type (e.g. StackAddress) through folding.

Source

pub fn push_literal(&self, literal: Literal) -> LiteralId

Pushes a Literal with arbitrary fields (e.g. with a symbolic ref) without interning. Use get_or_make_typed_literal for plain integer constants.

Source

pub fn add_synthetic_callee( &mut self, caller: FunctionId, callee_addr: u64, ) -> bool

Records a synthetic forward call-graph edge caller → callee_addr (see synthetic_callees). Returns true if the edge was newly added, so callers can drive a fixpoint without spinning.

Source

pub fn synthetic_callees_of( &self, caller: FunctionId, ) -> impl Iterator<Item = u64> + '_

Returns the synthetic callee entry addresses recorded for caller.

Source

pub fn push_varnode(&mut self, varnode: Varnode<'str>) -> VarnodeId

Source

pub fn push_poison(&self, type_id: TypeId) -> PoisonId

Mints a fresh typed poison value. Never deduped: each call yields a distinct PoisonId so GVN keeps every poison in its own congruence class.

Trait Implementations§

Source§

impl<'str> Clone for ValueRegistry<'str>

Source§

fn clone(&self) -> ValueRegistry<'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> Default for ValueRegistry<'str>

Source§

fn default() -> ValueRegistry<'str>

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

impl<'de, 'str> Deserialize<'de> for ValueRegistry<'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 ValueRegistry<'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 ValueRegistry<'str>

§

impl<'str> RefUnwindSafe for ValueRegistry<'str>

§

impl<'str> Send for ValueRegistry<'str>

§

impl<'str> Sync for ValueRegistry<'str>

§

impl<'str> Unpin for ValueRegistry<'str>

§

impl<'str> UnsafeUnpin for ValueRegistry<'str>

§

impl<'str> UnwindSafe for ValueRegistry<'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.