Expand description
Intra-block dead store elimination.
Walks each basic block backward to determine which stack positions are live (will be read
by a later instruction or at the block exit). Instructions whose outputs are all dead and
whose logic is safe to eliminate are marked InstFlags::NOOP.
DUP, SWAP, POP, DUPN, SWAPN, and EXCHANGE require custom liveness transfer functions
because generic (inputs, outputs) arity doesnβt capture how they map stack slots:
- SWAP/SWAPN permute two positions without consuming or producing values.
- DUP/DUPN copy a single deep source to a new TOS.
- EXCHANGE swaps two arbitrary non-TOS positions.
- POP kills its input (makes the position dead) rather than reading it.
EnumsΒ§
- Decoded
Imm π - Decoded immediate for liveness transfer of DUPN/SWAPN/EXCHANGE.
FunctionsΒ§
- all_
outputs_ πdead - Returns
trueif all positions actually written by the instruction are dead. - can_
skip_ πwhen_ dead - Returns
trueif the opcodeβs logic is safe to skip when its outputs are dead. - generic_
transfer π - Generic liveness transfer: kill all outputs, then mark all inputs as live.
- swap_
all_ πdead - SWAP dead check: both TOS and the swapped position must be dead.
- transfer_
dup π - DUP liveness: the new TOS is killed; if it was live, the source becomes live.
- transfer_
liveness π - Backward liveness transfer for a single instruction.
- transfer_
swap π - SWAP liveness: permute liveness of TOS and the swapped position.