Skip to content

Fix Precompute visitArrayGet missing memory ordering check#8327

Open
sumleo wants to merge 1 commit intoWebAssembly:mainfrom
sumleo:fix-precompute-array-atomic-ordering
Open

Fix Precompute visitArrayGet missing memory ordering check#8327
sumleo wants to merge 1 commit intoWebAssembly:mainfrom
sumleo:fix-precompute-array-atomic-ordering

Conversation

@sumleo
Copy link
Contributor

@sumleo sumleo commented Feb 16, 2026

Summary

  • visitStructGet in the precompute pass correctly checks MemoryOrder before allowing precomputation of immutable fields—blocking SeqCst entirely and blocking shared AcqRel—but visitArrayGet skips this check.
  • This causes array.atomic.get with SeqCst or AcqRel ordering on immutable array elements to be incorrectly constant-folded, removing synchronization semantics.
  • Added the same MemoryOrder switch to visitArrayGet matching the existing pattern in visitStructGet.

Test plan

  • Extended test/lit/passes/precompute-gc-atomics.wast with array versions of all six existing struct atomic get test cases (unordered/seqcst/acqrel x shared/unshared), verifying array atomics now follow the same optimization rules as struct atomics.

visitStructGet correctly checks MemoryOrder before allowing precomputation
of immutable fields (blocking SeqCst and shared AcqRel), but visitArrayGet
skips this check entirely. This causes array.atomic.get with SeqCst or
AcqRel ordering on immutable array elements to be incorrectly folded to
constants, removing synchronization semantics.

Add the same MemoryOrder switch to visitArrayGet matching the pattern
in visitStructGet, and extend the existing precompute-gc-atomics test
with array versions of all struct atomic get test cases.
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.

1 participant