Skip to content

[Heap2Local] Handle newly unreachable refs in cmpxchg and cast_desc_eq - #9272

Open
tlively wants to merge 1 commit into
mainfrom
heap2local-unreachable-ref
Open

tlively wants to merge 1 commit into
mainfrom
heap2local-unreachable-ref

Conversation

@tlively

@tlively tlively commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Struct2Local rewrites expressions in a post-order walk while deferring ReFinalize until the end of the function walk. When an unescaping allocation flows into both a failing cast inside the ref operand of a struct.atomic.rmw.cmpxchg, array.atomic.rmw.cmpxchg, or nullable ref.cast_desc_eq and into its expected or desc operand, the inner cast is replaced with an unreachable block before the parent expression is visited. Because ReFinalize has not run yet, the parent's curr->type remains concrete while curr->ref->type is now Type::unreachable, causing curr->ref->type.with(Nullable) or builder.addVar(func, curr->ref->type) to fail assertions or produce invalid IR. Check for curr->ref->type == Type::unreachable in visitStructCmpxchg, visitArrayCmpxchg, and visitRefCast.

`Struct2Local` rewrites expressions in a post-order walk while deferring `ReFinalize` until the end of the function walk. When an unescaping allocation flows into both a failing cast inside the `ref` operand of a `struct.atomic.rmw.cmpxchg`, `array.atomic.rmw.cmpxchg`, or nullable `ref.cast_desc_eq` and into its `expected` or `desc` operand, the inner cast is replaced with an unreachable block before the parent expression is visited. Because `ReFinalize` has not run yet, the parent's `curr->type` remains concrete while `curr->ref->type` is now `Type::unreachable`, causing `curr->ref->type.with(Nullable)` or `builder.addVar(func, curr->ref->type)` to fail assertions or produce invalid IR. Check for `curr->ref->type == Type::unreachable` in `visitStructCmpxchg`, `visitArrayCmpxchg`, and `visitRefCast`.
@tlively
tlively requested a review from a team as a code owner October 16, 2026 22:07
@tlively
tlively requested review from aheejin and removed request for a team October 16, 2026 22:07
@kripken

kripken commented Oct 16, 2026

Copy link
Copy Markdown
Member

Wait, wasn't that SIMD issue fixed by #9267 ?

@tlively tlively changed the title Fix missing SIMD validation error (#9267) [Heap2Local] Handle newly unreachable refs in cmpxchg and cast_desc_eq Oct 17, 2026
@tlively

tlively commented Oct 17, 2026

Copy link
Copy Markdown
Member Author

Yep, sorry. This got uploaded with the wrong PR title and message. Fixed now. This has happened a couple times now, so I'll try to add a safeguard against it in my local workflow.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants