Skip to content

Cranelift: Remove the stack_{load,store} instructions#13580

Open
fitzgen wants to merge 1 commit into
bytecodealliance:mainfrom
fitzgen:wasmtime-remove-stack-load-store
Open

Cranelift: Remove the stack_{load,store} instructions#13580
fitzgen wants to merge 1 commit into
bytecodealliance:mainfrom
fitzgen:wasmtime-remove-stack-load-store

Conversation

@fitzgen
Copy link
Copy Markdown
Member

@fitzgen fitzgen commented Jun 5, 2026

These get immediately legalized to stack_addr and load or store, so frontends should just emit that pair directly. For convenience and backwards compat, we add InstBuilder::stack_load and InstBuilder::stack_store methods 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 a TargetFrontendConfig to FuncBuilder::finalize, which resulted in a bit of churn, but is fully mechanical.

These get immediately legalized to `stack_addr` and `load` or `store`, so
frontends should just emit that pair directly. For convenience and backwards
compat, we add `InstBuilder::stack_load` and `InstBuilder::stack_store` methods
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 a
`TargetFrontendConfig` to `FuncBuilder::finalize`, which resulted in a bit of
churn, but is fully mechanical.
@fitzgen fitzgen requested review from a team as code owners June 5, 2026 23:00
@fitzgen fitzgen requested review from alexcrichton and removed request for a team June 5, 2026 23:00
Copy link
Copy Markdown
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to avoid changing finalize by looking at the stack slot's size field and choosing an appropriate type based on that?

@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator cranelift:meta Everything related to the meta-language. labels Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:meta Everything related to the meta-language. cranelift Issues related to the Cranelift code generator

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants