Skip to content

Preserve stores across divergent loops - #14636

Closed
agourakis82 wants to merge 2 commits into
bytecodealliance:mainfrom
agourakis82:fix/14573-divergent-store
Closed

agourakis82 wants to merge 2 commits into
bytecodealliance:mainfrom
agourakis82:fix/14573-divergent-store

Conversation

@agourakis82

Copy link
Copy Markdown
Contributor

Fixes #14573.

Dead-store elimination can remove a trapping store before a loop because a later store post-dominates it. If execution stays in the loop, the overwriter never executes, turning an immediate trap into a hang.

Mark the last-store state as observed on CFG edges that do not decrease DFS postorder. Every cycle contains such an edge, including irreducible cycles. This conservatively limits DSE across cycles while retaining cross-block elimination in acyclic control flow.

The regression test covers infinite loops, loops with exit edges, stores in divergent blocks, irreducible cycles, non-trapping stores, and an acyclic control case.

Validation:

  • 49 alias filetests passed.
  • 212 cranelift-codegen library tests passed.
  • Formatting and diff checks passed.
  • A local concurrent shared-memory experiment observed the intermediate store with the patch and failed against the original revision.

The shared-memory experiment is supplementary evidence because it depends on thread scheduling. A local debug-build timing comparison measured a 2.05% increase in median end-to-end filetest time; production throughput and isolated pass cost have not been measured.

Signed-off-by: Demetrios Agourakis demetrios@agourakis.med.br<!--
Please make sure you include the following information:

  • If this work has been discussed elsewhere, please include a link to that
    conversation. If it was discussed in an issue, just mention "issue #...".

  • Explain why this change is needed. If the details are in an issue already,
    this can be brief.

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

Signed-off-by: Demetrios Agourakis <demetrios@agourakis.med.br>
Signed-off-by: Demetrios Agourakis <demetrios@agourakis.med.br>
@agourakis82
agourakis82 requested a review from a team as a code owner October 9, 2026 20:22
@agourakis82
agourakis82 requested review from fitzgen and removed request for a team October 9, 2026 20:22
@cfallin

cfallin commented Oct 9, 2026

Copy link
Copy Markdown
Member

#14632 already fixes this and is in the merge queue, so closing this as a duplicate fix -- thanks though!

@cfallin cfallin closed this Oct 9, 2026
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.

Cranelift: dead-store elimination removes a trapping store before a non-terminating loop

2 participants