Conversation
…y#8850) Add RMW result tracking infrastructure to handle cases where an inner cmpxchg result flows into the value operand of an outer xchg. - Add RMWResultInfo struct and RMWResultInfoMap - Extend EscapeAnalyzer to follow RMW result flows - Modify visitStructRMW and visitStructCmpxchg to detect nested flows - Store reference-typed RMW results in scratch locals for downstream use Fixes WebAssembly#8850.
|
Was this bug not already fixed by #8857? |
|
@tlively, Given the diff shows only Thanks for the question. I looked into this more carefully and the picture is different from what I assumed when I opened the PR. I compared the test file on main and on this branch: git show main:test/lit/passes/heap2local-rmw.wast > /tmp/main.wast
git show fix-heap2local-rmw-tracking-8850:test/lit/passes/heap2local-rmw.wast > /tmp/pr.wast
diff /tmp/main.wast /tmp/pr.wastThe only differences are in I also ran the nested RMW reproducer on both branches: ./bin/wasm-opt nested-rmw.wast --heap2local --fuzz-exec -allThe fuzz-exec self-check — which runs the module before and after optimization and compares the results — passes on both main and this branch. The output is identical. So main already handles the nested case correctly. You were right in your original question. Since |
This PR fixes a bug in
Heap2Localwhere nested atomicRMWoperationswere incorrectly optimized.
When an inner cmpxchg result flows into the value operand of an outer
xchg, the pass now correctly tracks this data flow and preserves theRMWoperations while localizing their ref operands.The fix adds RMW result tracking infrastructure (
RMWResultInfo) andextends
EscapeAnalyzer,visitStructRMW, andvisitStructCmpxchgto handle nested flows.
Tested with:
heap2local-rmw.wastlit testAll tests pass (4 d8-related failures are unrelated and due to local
environment).
Fixes #8850.