cfallin opened PR #12447 from cfallin:preserve-all-no-returns to bytecodealliance:main:
In #12399 a fuzzbug uncovered an issue whereby a function with
preserve_alland with many return values cannot be called, becauseemit_retval_loadscannot codegen memory-to-memory moves (from on-stack return value slots directly to spillslots) without a temporary/clobberable register, andpreserve_allimplies no such registers exist.I thought about trying to support this by shuffling registers -- such a case implies many return values, and at least some of them will be in registers, so we might be able to temporarily spill one of those and use it as a scratch to move other values memory-to-memory. But the complexity doesn't seem worthwhile, and this path is not actually needed at the moment.
Thinking more broadly, anyone using
preserve_allfor hooks meant to minimally perturb register state will likely not want to use many return values anyway (that defeats the point). We could allow one return value, with the knowledge that this always fits in a register in our existing ABIs, but that also feels somewhat arbitrary, and I could make the argument that "preserve all" should really mean preserve all. Someone wanting to return a value anyway from such a hook could use indirect means (pass in a pointer to a stackslot, for example). I'm happy to tweak this limit if others have more thoughts, however.Fixes #12399.
<!--
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
-->
cfallin requested wasmtime-compiler-reviewers for a review on PR #12447.
cfallin requested alexcrichton for a review on PR #12447.
github-actions[bot] added the label cranelift on PR #12447.
github-actions[bot] added the label cranelift:area:machinst on PR #12447.
fitzgen submitted PR review:
SGTM!
fitzgen added PR #12447 Cranelift: preserve_all: disallow return values. to the merge queue
github-merge-queue[bot] removed PR #12447 Cranelift: preserve_all: disallow return values. from the merge queue
cfallin commented on PR #12447:
Spurious CI failure in a MinGW package download; retrying.
cfallin added PR #12447 Cranelift: preserve_all: disallow return values. to the merge queue
cfallin merged PR #12447.
cfallin removed PR #12447 Cranelift: preserve_all: disallow return values. from the merge queue
Last updated: Jan 29 2026 at 13:25 UTC