Amanieu opened PR #11213 from Amanieu:regalloc3 to bytecodealliance:main:
This is based on https://github.com/bytecodealliance/regalloc2/pull/230 which adds regalloc3 as a back-end to regalloc2.
Only one change had to be made to codegen: tail calls were reserving
r11as a scratch register by making it a def on the return instruction. This is not supported by regalloc3, which allows it extends all live ranges to the end ofretinstruction so that the live range segment can merge with the next one. Since a def on a return instruction is meaningless, I've changed it to a hard-coded register in the emit stage instead.
Amanieu requested cfallin for a review on PR #11213.
Amanieu requested alexcrichton for a review on PR #11213.
Amanieu requested wasmtime-core-reviewers for a review on PR #11213.
Amanieu requested wasmtime-compiler-reviewers for a review on PR #11213.
Amanieu requested wasmtime-default-reviewers for a review on PR #11213.
Amanieu updated PR #11213.
Amanieu updated PR #11213.
github-actions[bot] commented on PR #11213:
Subscribe to Label Action
cc @cfallin, @fitzgen
<details>
This issue or pull request has been labeled: "cranelift", "cranelift:area:machinst", "cranelift:area:x64", "cranelift:meta", "isle", "wasmtime:api", "wasmtime:config"Thus the following users have been cc'd because of the following labels:
- cfallin: isle
- fitzgen: isle
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
github-actions[bot] commented on PR #11213:
Label Messager: wasmtime:config
It looks like you are changing Wasmtime's configuration options. Make sure to
complete this check list:
[ ] If you added a new
Configmethod, you wrote extensive documentation for
it.<details>
Our documentation should be of the following form:
```text
Short, simple summary sentence.More details. These details can be multiple paragraphs. There should be
information about not just the method, but its parameters and results as
well.Is this method fallible? If so, when can it return an error?
Can this method panic? If so, when does it panic?
Example
Optional example here.
```</details>
[ ] If you added a new
Configmethod, or modified an existing one, you
ensured that this configuration is exercised by the fuzz targets.<details>
For example, if you expose a new strategy for allocating the next instance
slot inside the pooling allocator, you should ensure that at least one of our
fuzz targets exercises that new strategy.Often, all that is required of you is to ensure that there is a knob for this
configuration option in [wasmtime_fuzzing::Config][fuzzing-config] (or one
of its nestedstructs).Rarely, this may require authoring a new fuzz target to specifically test this
configuration. See [our docs on fuzzing][fuzzing-docs] for more details.</details>
[ ] If you are enabling a configuration option by default, make sure that it
has been fuzzed for at least two weeks before turning it on by default.[fuzzing-config]: https://github.com/bytecodealliance/wasmtime/blob/ca0e8d0a1d8cefc0496dba2f77a670571d8fdcab/crates/fuzzing/src/generators.rs#L182-L194
[fuzzing-docs]: https://docs.wasmtime.dev/contributing-fuzzing.html
<details>
To modify this label's message, edit the <code>.github/label-messager/wasmtime-config.md</code> file.
To add new label messages or remove existing label messages, edit the
<code>.github/label-messager.json</code> configuration file.</details>
Amanieu updated PR #11213.
github-actions[bot] commented on PR #11213:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "fuzzing"Thus the following users have been cc'd because of the following labels:
- fitzgen: fuzzing
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
fitzgen submitted PR review:
LGTM modulo comment below, removing the
[patch.crates-io]bits when upstream is ready, and getting CI passing.
fitzgen created PR review comment:
This might be true for our current calling conventions, but is not guaranteed to continue to hold true in the future. As such, could you assert that
call_info.usesdoesn't contain any uses ofr11to future proof this code?
Amanieu submitted PR review.
Amanieu created PR review comment:
Actually, I've been over-thinking this. We can keep the existing code and just change it to an early-def, which is allowed by regalloc3 on return instructions. It could even be changed to an arbitrary register constraint in the future once regalloc2 support is dropped.
Amanieu updated PR #11213.
Amanieu updated PR #11213.
Amanieu submitted PR review.
Amanieu created PR review comment:
Actually an arbitrary register wouldn't work since it could conflict with callee-saved registers. I've added the assert as you suggested.
Amanieu commented on PR #11213:
Regarding CI, there are currently 3 issues:
- regalloc3 depends on brie-tree (fast B-Tree implementation) which has an MSRV of 1.88.
- brie-tree uses allocator-api 0.3 but other dependencies of wasmtime use allocator-api 0.2. This fails cargo deny due to the duplicate dependency.
- regalloc3/brie-tree probably need to be vetted. But this can wait until the crate is actually published.
cfallin closed without merge PR #11213.
cfallin commented on PR #11213:
As noted in bytecodealliance/regalloc2#230, Cranelift maintainers have decided not to take regalloc3 at this time due to maintenance-burden concerns, so I'll go ahead and close this. Thank you for all the effort regardless!
Last updated: Dec 06 2025 at 07:03 UTC