fitzgen opened PR #14111 from fitzgen:undo-last-store-on-dse to bytecodealliance:main:
Alias analysis's dead-store elimination removed the dead store's
mem_values
entry, but left the region's last-store slot naming the instruction it had just
deleted. Leaving the removed-store meant that when we then reprocess the
overwriting store, we keyed its lookup on a removed instruction, found nothing,
and failed to notice that (for example) the overwriting store became idempotent
and could also be removed.With this commit, each store now records the memory version it displaced, and
eliminating a dead store rolls that version back, so a chain likev1 = load.i32 region0 v0 store region0 v2, v0 ;; dead store region0 v1, v0 ;; idempotent once the dead store is gonecollapses in the single pass we actually make, rather than removing only one
link in the chain and requiring that we do N passes to fully clean up a chain of
N dead/idempotent stores. This code pattern the shape fused sync adapters emit
around theMAY_LEAVEflag and the relevant disas tests each lose a store as a
result.Depends on https://github.com/bytecodealliance/wasmtime/pull/14109
fitzgen requested alexcrichton for a review on PR #14111.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #14111.
fitzgen requested wasmtime-core-reviewers for a review on PR #14111.
alexcrichton requested cfallin for a review on PR #14111.
alexcrichton unassigned alexcrichton from PR #14111 Cranelift: unwind last-store state after removing a dead store.
:thumbs_up: cfallin submitted PR review:
This looks right to me -- thanks for the detailed comments!
I was initially worried/trying to reason through the "patch" to analysis state with respect to possible inconsistencies with state propagated elsewhere. The thing that makes this work is that we only do the undo when the thing in the slot (whatever it is) is not observed; so we're free to change it.
cfallin commented on PR #14111:
(merge conflict at the moment)
github-actions[bot] added the label cranelift on PR #14111.
fitzgen updated PR #14111.
fitzgen has enabled auto merge for PR #14111.
fitzgen added PR #14111 Cranelift: unwind last-store state after removing a dead store to the merge queue.
:check: fitzgen merged PR #14111.
fitzgen removed PR #14111 Cranelift: unwind last-store state after removing a dead store from the merge queue.
Last updated: Aug 30 2026 at 09:07 UTC