Skip to content

SSA CFG: stack to memory spilling#16767

Open
clonker wants to merge 6 commits into
developfrom
ssa-cfg-kiss-memspill
Open

SSA CFG: stack to memory spilling#16767
clonker wants to merge 6 commits into
developfrom
ssa-cfg-kiss-memspill

Conversation

@clonker
Copy link
Copy Markdown
Member

@clonker clonker commented May 22, 2026

Implements stack to memory spilling for the SSA CFG pipeline in a simple stupid version.

Adds:

  • ssa/spill/MemoryAddressing is a per-subobject owner of spill memory
    • sums numSpilled() across each CFGs SpillSet and bumps memory guard accordingly, allocates non-overlapping memory addresses for spilled values
  • ssa/spill/Emitter emits bytecode against the symbolic stack for spilled values
  • ssa/spill/SpillSet got a new method feasilize which will check for all spilled values whether they can be feasibly spilled at the point of origin, may add more things to spill accordingly

Modifies

  • ssa/StackLayoutGenerators generate() to return {layout, spillSet} instead of just the layout and also validates back-edges asserting that back-edge targets can be safely shuffled to
  • ssa/CodeTransform is reworked to first generate per-CFG layouts and spill sets (feasilize them), then build a single global MemoryAddressing to hand into the CodeTransform instance

Test

  • Adds SpillTest suite under test/libyul/ssa/spill which runs the generate -> feasilize -> address sequence and emits that plus a text representation of the input object. does not generate any code.

@clonker clonker marked this pull request as ready for review May 22, 2026 09:27
@clonker clonker requested a review from blishko May 22, 2026 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant