Expand description
Computes the points where each local must have a distinct allocation.
The result is a SparseIntervalMatrix with one row per local. Two locals
may share the same address only if their rows are disjoint. To model MIR
statements where a source operand and destination place may share an
address, each statement and terminator is split into an early point, where
operands are read, and a late point, where destinations are written.
A local live range starts at the late point of any statement or terminator
that writes to it without a Deref projection. It ends at StorageLive or
StorageDead, or at the early point of a whole-local move operand or the
last use of that local on a control-flow path (only for locals whose address
is never observed). This happens at StorageLive because it resets a local
to an uninitialized state.
Call terminators are handled specially: move operands are kept live
through the late point of the terminator so they conflict with each other
and with the destination place. This matches the runtime behavior where the
place is donated to the callee for the duration of the call.
The analysis consists of three passes:
- A backward value-liveness analysis which identifies the last point at which each local is directly used in each control flow path. This is used to shorten the lifetime of unborrowed locals to their last use.
- A forward allocation-liveness analysis which uses that information together with writes, moves, and storage markers to compute which allocations may be live on entry to each block.
- A final walk using those entry states which constructs the matrix and distinguishes whether each effect happens at the early or late point of a statement or terminator.
StructsΒ§
- Kill
Points π - Kill
Points πVisitor - Matrix
Builder π - Helper type to construct a
SparseIntervalMatrix. - Precise
Liveness π - Split
Point Index - A
PointIndexwith the lower bit encoding early/late inside a statement. - Visit
Allocated Locals With - Visits locals that are implicitly allocated by a statement or terminator as part of destination place evaluation.
- Visit
Deallocated Locals With - Visits locals that are implicitly freed by being evaluated as a bare-local move operand or through a storage statement.
EnumsΒ§
- Split
Point Effect - Different βphasesβ of a single MIR statement, used to describe how overlapping operands are handled.