Skip to content

Fix treeify soundness: never treeify (sink) effectful ops at all.#18

Merged
cfallin merged 1 commit into
mainfrom
fix-treeify
Jul 24, 2026
Merged

Fix treeify soundness: never treeify (sink) effectful ops at all.#18
cfallin merged 1 commit into
mainfrom
fix-treeify

Conversation

@cfallin

@cfallin cfallin commented Jul 23, 2026

Copy link
Copy Markdown
Member

The last_non_pure adjacency rule let a non-pure value (e.g. a load) be owned by its adjacent consumer; when that consumer's pure single-use chain was itself treeified under a later use, the load's code was emitted at the final owner's position, possibly sinking past intervening effects, including stores to the same address.

Rather than build a full reordering analysis, this PR simply forces all non-pure ops to stay in-place as their own tree. This increases Wasm code size slightly (traffic through allocated locals to consume the result of every load), but in an optimizing Wasm engine the end result will be the same.

The `last_non_pure` adjacency rule let a non-pure value (e.g. a load) be
owned by its adjacent consumer; when that consumer's pure single-use
chain was itself treeified under a later use, the load's code was
emitted at the final owner's position, possibly sinking past intervening
effects, including stores to the same address.

Rather than build a full reordering analysis, this PR simply forces all
non-pure ops to stay in-place as their own tree. This increases Wasm
code size slightly (traffic through allocated locals to consume the
result of every load), but in an optimizing Wasm engine the end result
will be the same.
@cfallin
cfallin requested a review from fitzgen July 23, 2026 19:54
@cfallin
cfallin merged commit 183042d into main Jul 24, 2026
3 checks passed
@cfallin
cfallin deleted the fix-treeify branch July 24, 2026 16:55
@cfallin cfallin mentioned this pull request Jul 24, 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.

2 participants