fitzgen opened PR #13580 from fitzgen:wasmtime-remove-stack-load-store to bytecodealliance:main:
These get immediately legalized to
stack_addrandloadorstore, so frontends should just emit that pair directly. For convenience and backwards compat, we addInstBuilder::stack_loadandInstBuilder::stack_storemethods that emit the pair as a single operation. Unfortunately, these methods have to take an additional pointer-type parameter that the old version didn't have to take because the rewrite didn't happen until legalization time, so these new methods are not 100% backwards compatible. This also necessitated passing in aTargetFrontendConfigtoFuncBuilder::finalize, which resulted in a bit of churn, but is fully mechanical.<!--
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 alexcrichton for a review on PR #13580.
fitzgen requested wasmtime-compiler-reviewers for a review on PR #13580.
fitzgen requested wasmtime-core-reviewers for a review on PR #13580.
:memo: alexcrichton submitted PR review:
Would it be possible to avoid changing
finalizeby looking at the stack slot'ssizefield and choosing an appropriate type based on that?
github-actions[bot] added the label cranelift on PR #13580.
github-actions[bot] added the label cranelift:meta on PR #13580.
fitzgen commented on PR #13580:
Would it be possible to avoid changing
finalizeby looking at the stack slot'ssizefield and choosing an appropriate type based on that?Unfortunately not, because it isn't the stack slot's type that we need to pass in (that was already passed in) it is the size of the target pointer.
alexcrichton commented on PR #13580:
So, here, which I belive is the only need for changing
finalizecurrently, theslotvariable's size doesn't match the platform's pointer width?
fitzgen updated PR #13580.
fitzgen commented on PR #13580:
So, here, which I belive is the only need for changing
finalizecurrently,Correct, although I think it is very reasonable to require a target config when building CLIF in general (e.g. a small additional follow up refactor could make all the memcpy functions that want a target config as an argument stop taking that argument and using the same source of truth as finalize).
the
slotvariable's size doesn't match the platform's pointer width?It does not match. For Wasmtime, for example, the slots are 4 bytes large (
VMGcRef-sized) regardless of 64- or 32-bit target. In general, those slots are sized to the value that needs inclusion in stack maps, which can be of any arbitrary type.
fitzgen has enabled auto merge for PR #13580.
:thumbs_up: alexcrichton submitted PR review:
Ah right, indeed. Would it make sense to take in an entire
&dyn TargetIsahere instead of just theTargetFrontendConfig? Or alternatively just take thepointer_typeinstead ofTargetFrontendConfig?
fitzgen added PR #13580 Cranelift: Remove the stack_{load,store} instructions to the merge queue.
fitzgen commented on PR #13580:
Ah right, indeed. Would it make sense to take in an entire
&dyn TargetIsahere instead of just theTargetFrontendConfig? Or alternatively just take thepointer_typeinstead ofTargetFrontendConfig?Other frontend methods (such as the memcpy stuff mentioned earlier) take
TargetFrontendConfigso I was just trying to match that.All we absolutely need is the pointer type but it feels a bit like overspecializing on the exact use case today, vs what feels "right" / fits with the design of the crate.
&dyn TargetIsais a bit more of a mid-end/backend thing, for example.
:check: fitzgen merged PR #13580.
fitzgen removed PR #13580 Cranelift: Remove the stack_{load,store} instructions from the merge queue.
Last updated: Jul 29 2026 at 05:03 UTC