pub struct Liveness { /* private fields */ }Expand description
What is live at the edges of every block.
Per block rather than per instruction, because the sets inside a block are recoverable from the
live-out by walking the block backwards and nothing wants to pay for storing them.
Liveness::through is that walk, and the pressure model is its first caller.
Implementations§
Source§impl Liveness
impl Liveness
Sourcepub fn live_in(&self, block: Block) -> impl Iterator<Item = Value> + use<'_>
pub fn live_in(&self, block: Block) -> impl Iterator<Item = Value> + use<'_>
What is live when control arrives at the block, which excludes its own parameters.
Sourcepub fn live_out(&self, block: Block) -> impl Iterator<Item = Value> + use<'_>
pub fn live_out(&self, block: Block) -> impl Iterator<Item = Value> + use<'_>
What is live when control leaves it.
Sourcepub fn is_live_in(&self, block: Block, value: Value) -> bool
pub fn is_live_in(&self, block: Block, value: Value) -> bool
Whether that value is live on the way in.
Sourcepub fn is_live_out(&self, block: Block, value: Value) -> bool
pub fn is_live_out(&self, block: Block, value: Value) -> bool
Whether that value is live on the way out.
Sourcepub fn through(
&self,
func: &Func,
block: Block,
at: impl FnMut(Inst, &LiveHere<'_>),
)
pub fn through( &self, func: &Func, block: Block, at: impl FnMut(Inst, &LiveHere<'_>), )
Walks the block backwards from its live-out, calling at before each instruction with what
is live there.
This is where the per instruction sets come from, for the callers that want them. The set
handed to at is what is live just before that instruction runs, so it holds the
instruction’s operands and not its results.
Sourcepub fn changes(&self, func: &Func, block: Block, at: impl FnMut(Inst, &Change))
pub fn changes(&self, func: &Func, block: Block, at: impl FnMut(Inst, &Change))
The same walk, reporting what each instruction changes rather than what is live.
Liveness::through hands out the whole set at every instruction, and a caller that only
wants to count what is in it pays the size of the set per instruction. In a function of a
hundred and ninety thousand instructions the set is thousands of values wide and that is
quadratic. What actually changes at an instruction is its results and its operands, so a
caller keeping a running count can be handed those instead and stay linear.
tamnd/rucc#1015.