Enum VariableOrigin
pub enum VariableOrigin {
Argument(u16),
Local(u16),
Phi,
EntryLiveIn,
}Expand description
The origin of an SSA variable - where it came from in the original CIL.
This enum tracks the semantic source of each SSA variable, which is useful for debugging, optimization decisions, and mapping back to source code.
§CIL Variable Mapping
| CIL Instruction | Variable Origin |
|---|---|
ldarg.N, ldarg.s, ldarg | Argument(N) |
ldloc.N, ldloc.s, ldloc | Local(N) |
| Stack operations (add, call, etc.) | Local(num_locals + K) |
| Phi node result | Phi |
§Machine-code front ends
The four variants above describe a CIL method, which has a declared
signature and a declared local table. A machine-code lifter has neither: a
register read before any write in the function body is a value the caller
supplied, but its position in the (unrecovered) signature is unknown at lift
time. That case is EntryLiveIn — not Argument, which
would assert a signature position the lifter cannot yet know.
§Examples
use analyssa::ir::variable::VariableOrigin;
let arg_origin = VariableOrigin::Argument(0); // First method argument
let local_origin = VariableOrigin::Local(2); // Third local variable
let phi_origin = VariableOrigin::Phi; // From phi node
let live_in = VariableOrigin::EntryLiveIn; // Caller-supplied, position unknownVariants§
Argument(u16)
Method argument (parameter).
The index corresponds to the argument’s position in the method signature.
For instance methods, argument 0 is this.
Local(u16)
Local variable declared in the method.
The index corresponds to the local’s position in the local variable
signature (accessed via ldloc/stloc). Local(idx) always refers
to a real CIL local. Stack temporaries and other synthetics use
Phi origin instead.
Phi
Result of a phi node at a control flow merge.
Phi nodes are synthetic - they don’t correspond to any CIL instruction but rather represent the merging of values from different control flow paths.
EntryLiveIn
A value live on entry to the function, supplied by the caller, whose position in the signature is not known.
Produced by machine-code front ends for a storage location (typically a
register) that is read before the function body ever writes it. Like
Argument it needs no definition in the body — the
verifier treats it as entry-defined — but unlike Argument it makes no
claim about argument position, because at lift time the calling
convention has not been recovered.
ABI recovery may later reclassify such a variable as a real
Argument(n); until it does, this is the honest description.
Implementations§
Source§impl VariableOrigin
impl VariableOrigin
Sourcepub const fn is_argument(&self) -> bool
pub const fn is_argument(&self) -> bool
Returns true if this is an argument origin.
Sourcepub const fn is_entry_live_in(&self) -> bool
pub const fn is_entry_live_in(&self) -> bool
Returns true if this is a caller-supplied value live on function entry.
Sourcepub const fn is_caller_supplied(&self) -> bool
pub const fn is_caller_supplied(&self) -> bool
Returns true if the caller supplies this value, so it needs no
definition in the function body.
True for both Argument (position known) and
EntryLiveIn (position not yet recovered).
Sourcepub const fn argument_index(&self) -> Option<u16>
pub const fn argument_index(&self) -> Option<u16>
Returns the argument index if this is an argument origin.
Sourcepub const fn local_index(&self) -> Option<u16>
pub const fn local_index(&self) -> Option<u16>
Returns the local index if this is a local variable origin.
Trait Implementations§
Source§impl Clone for VariableOrigin
impl Clone for VariableOrigin
Source§fn clone(&self) -> VariableOrigin
fn clone(&self) -> VariableOrigin
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for VariableOrigin
Source§impl Debug for VariableOrigin
impl Debug for VariableOrigin
Source§impl Display for VariableOrigin
impl Display for VariableOrigin
impl Eq for VariableOrigin
Source§impl Hash for VariableOrigin
impl Hash for VariableOrigin
Source§impl Ord for VariableOrigin
impl Ord for VariableOrigin
Source§fn cmp(&self, other: &VariableOrigin) -> Ordering
fn cmp(&self, other: &VariableOrigin) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for VariableOrigin
impl PartialEq for VariableOrigin
Source§impl PartialOrd for VariableOrigin
impl PartialOrd for VariableOrigin
impl StructuralPartialEq for VariableOrigin
Auto Trait Implementations§
impl Freeze for VariableOrigin
impl RefUnwindSafe for VariableOrigin
impl Send for VariableOrigin
impl Sync for VariableOrigin
impl Unpin for VariableOrigin
impl UnsafeUnpin for VariableOrigin
impl UnwindSafe for VariableOrigin
Blanket Implementations§
impl<T> Boilerplate for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more