SSA CFG: stack to memory spilling#16767
Merged
Merged
Conversation
blishko
reviewed
May 27, 2026
b93b4ac to
821b1df
Compare
blishko
reviewed
Jun 4, 2026
ceb18c3 to
633b9db
Compare
blishko
reviewed
Jun 9, 2026
blishko
left a comment
Contributor
There was a problem hiding this comment.
Nice! I have just a few small comments, but I think we can merge this today!
633b9db to
6300a56
Compare
Contributor
|
@clonker can you update the PR description to use the new method name instead of |
Dual to `dupDeepSlotIfRequired`: A deep, still-incorrect target slot whose wanted value is not on the stack at all. A push/dup grows the stack, pushing that slot one deeper. So if the deepest incorrect args slot would be pushed out of reach by growing, shrink first to keep it reachable.
…ng what to swap into a specific offset
6300a56 to
c48728e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements stack to memory spilling for the SSA CFG pipeline in a simple stupid version.
Adds:
ssa/spill/MemoryAddressingis a per-subobject owner of spill memorynumSpilled()across each CFGsSpillSetand bumps memory guard accordingly, allocates non-overlapping memory addresses for spilled valuesssa/spill/Emitteremits bytecode against the symbolic stack for spilled valuesssa/spill/SpillSetgot a new methodcloseUnderReachabilityConstraintswhich will check for all spilled values whether they can be feasibly spilled at the point of origin, may add more things to spill accordinglyModifies
ssa/StackLayoutGeneratorsgenerate()to return{layout, spillSet}instead of just the layout and also validates back-edges asserting that back-edge targets can be safely shuffled tossa/CodeTransformis reworked to first generate per-CFG layouts and spill sets (and close them under reachability constraints), then build a single globalMemoryAddressingto hand into theCodeTransforminstanceTest
SpillTestsuite undertest/libyul/ssa/spillwhich runs thegenerate->closeUnderReachabilityConstraints->addresssequence and emits that plus a text representation of the input object. does not generate any code.