Repository navigation
[Heap2Local2] Support struct and array cmpxchg - #9415
Merged
Merged
Conversation
Model struct.atomic.rmw.cmpxchg and array.atomic.rmw.cmpxchg in Heap2Local2 by linking expected and replacement origins as conditional escape edges (so replacement only escapes if expected can match a heap value at runtime) and lowering cmpxchg operations on non-escaping allocations or non-matching expected operands in Optimizer.
tlively
commented
Nov 21, 2026
| std::vector<NodeId> escapingNodes; | ||
| // Tracked cmpxchg sites where an escaping expected value forces replacement | ||
| // to escape. | ||
| std::vector<CmpxchgSite> cmpxchgSites; |
Member
Author
There was a problem hiding this comment.
We can't fold the cmpxchg edges into the normal graph like we did for cast edges because they are not dataflow edges at all and would have to be special-cased everywhere anyway.
kripken
approved these changes
Nov 23, 2026
kripken
left a comment
Member
There was a problem hiding this comment.
Nice improvements on the tests!
| // Conditional escape adjacency list: escapeAdj[u] lists replacement | ||
| // allocations v that must escape if expected allocation u escapes in a | ||
| // cmpxchg. Lazily allocated since candidate-to-candidate cmpxchg is rare. | ||
| std::vector<std::vector<AllocId>> escapeAdj; |
Member
There was a problem hiding this comment.
Maybe
Suggested change
| std::vector<std::vector<AllocId>> escapeAdj; | |
| std::vector<SmallVector<AllocId, 1>> escapeAdj; |
?
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.
Model struct.atomic.rmw.cmpxchg and array.atomic.rmw.cmpxchg in Heap2Local2 by linking expected and replacement origins as conditional escape edges (so replacement only escapes if expected can match a heap value at runtime) and lowering cmpxchg operations on non-escaping allocations or non-matching expected operands in Optimizer.