fitzgen opened PR #13713 from fitzgen:adapter-may-leave-reset-use-locals to bytecodealliance:main:
…imization
The clear-and-restore is now structured so that if translation doesn't actually call any functions (e.g. due to inlining) then a future dead-store elimination pass in Cranelift can remove all the flag juggling entirely (other than trapping when
!may_leave):may_leave = load vmctx+MAY_LEAVE_OFFSET ;; (0) trapz may_leave ... zero = iconst 0 store zero, vmctx+MAY_LEAVE_OFFSET ;; (1) ... store may_leave, vmctx+MAY_LEAVE_OFFSET ;; (2)First, the dead-store elimination pass will see that the the store at (1): is dead and remove it. Then, the idempotent-store eliminator will recognize that the store at (2) is storing the same value that the memory location already contains and it will also be removed. The more we can reuse locals to make this idempotency obvious, rather than force Cranelift's optimizer to rediscover this information, the better.
<!--
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.htmlPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
fitzgen requested cfallin for a review on PR #13713.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13713.
fitzgen requested wasmtime-core-reviewers for a review on PR #13713.
github-actions[bot] added the label wasmtime:api on PR #13713.
:thumbs_up: cfallin submitted PR review:
Great idea -- the separate may-leave flag global is of course a cost but it seems like that should be tiny compared to the advantages we get being able to reason about it separately. LGTM!
cfallin added PR #13713 Make clearing and restoring the may_leave flag more amenable to opt… to the merge queue.
:check: cfallin merged PR #13713.
cfallin removed PR #13713 Make clearing and restoring the may_leave flag more amenable to opt… from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC