Struct LivenessResult
pub struct LivenessResult { /* private fields */ }Expand description
Liveness analysis result for a whole program.
For each user-defined function, stores a per-statement live_after set:
live_after[i] is the set of variables live immediately after top-level
statement i in that function’s body.
Used by codegen to decide when an argument can be moved into a call instead of cloned: if a variable is not live after the call statement, the old value is never read again and ownership can be transferred.
Implementations§
§impl LivenessResult
impl LivenessResult
pub fn analyze(stmts: &[Stmt<'_>]) -> LivenessResult
pub fn analyze(stmts: &[Stmt<'_>]) -> LivenessResult
Compute liveness for every FunctionDef in stmts.
Algorithm: backward dataflow over the top-level statement list of each
function body. Return is treated as a terminator — variables used in
subsequent (dead-code) statements do not affect liveness before the
Return.
pub fn is_live_after(
&self,
fn_sym: Symbol,
stmt_idx: usize,
var: Symbol,
) -> bool
pub fn is_live_after( &self, fn_sym: Symbol, stmt_idx: usize, var: Symbol, ) -> bool
Returns true if var is live immediately after top-level statement
stmt_idx in function fn_sym.
Returns false for unknown functions, out-of-bounds indices, or when
the variable is definitely dead.
pub fn live_after(&self, fn_sym: Symbol, stmt_idx: usize) -> &HashSet<Symbol>
pub fn live_after(&self, fn_sym: Symbol, stmt_idx: usize) -> &HashSet<Symbol>
Returns the live-after set for statement stmt_idx in fn_sym.
Returns a reference to an empty set when the function or index is unknown.
Auto Trait Implementations§
impl Freeze for LivenessResult
impl RefUnwindSafe for LivenessResult
impl Send for LivenessResult
impl Sync for LivenessResult
impl Unpin for LivenessResult
impl UnsafeUnpin for LivenessResult
impl UnwindSafe for LivenessResult
Blanket Implementations§
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.