Live Variables and Backward Dataflow
Determine which current values can still be read and use the answer to separate dead assignments from necessary ones.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
A read makes a value live before the instruction
A variable is live at a point if some path reads its current value before overwriting it. For one block, use
\[ \mathrm{In}=\mathrm{Use}\cup(\mathrm{Out}\setminus\mathrm{Def}). \]
Here Use contains variables read before definition within the block. Out is the union of successors’ live-in sets in the ordinary non-SSA case. In SSA, incoming phi operands are uses on their specific predecessor edges. Iterate backward because later reads give earlier obligations.
Overwriting can end one lifetime and start another
In \(x:=x+1\), the current \(x\) is read before the new \(x\) supersedes it. In \(x:=7\), no old \(x\) is needed by the assignment. A definition whose newly written value is never live afterward can be removable if evaluating it has no observable effect. Dead-code elimination checks that qualification. Register allocation uses overlapping live values to decide which names require separate locations.[1][2]