Skip to main content

Module dead_store_elim

Module dead_store_elim 

Source
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Β§

DecodedImm πŸ”’
Decoded immediate for liveness transfer of DUPN/SWAPN/EXCHANGE.

FunctionsΒ§

all_outputs_dead πŸ”’
Returns true if all positions actually written by the instruction are dead.
can_skip_when_dead πŸ”’
Returns true if 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.