cranelift: Simplify spill/reload emission#8296
Merged
jameysharp merged 1 commit intobytecodealliance:mainfrom Apr 3, 2024
Merged
cranelift: Simplify spill/reload emission#8296jameysharp merged 1 commit intobytecodealliance:mainfrom
jameysharp merged 1 commit intobytecodealliance:mainfrom
Conversation
The `gen_spill` and `gen_reload` methods on `Callee` are used to emit appropriate moves between registers and the stack, as directed by the register allocator. These moves always apply to a single register at a time, even if that register was originally part of a group of registers. For example, when an I128 is represented using two 64-bit registers, either of those registers may be spilled independently. As a result, the `load_spillslot`/`store_spillslot` helpers were more general than necessary, which in turn required extra complexity in the `gen_load_stack_multi`/`gen_store_stack_multi` helpers. None of these helpers were used in any other context, so all that complexity was unnecessary. Inlining all four helpers and then simplifying eliminates a lot of code without changing the output of the compiler. These helpers were also the only uses of `StackAMode::offset`, so I've deleted that. While I was there, I also deleted `StackAMode::get_type`, which was introduced in bytecodealliance#8151 and became unused again in bytecodealliance#8246.
cfallin
approved these changes
Apr 3, 2024
Member
cfallin
left a comment
There was a problem hiding this comment.
Good catch! I think this is leftover generality from a previous version of multi-reg handling; indeed we don't seem to need it anymore. I'm having a little trouble remembering whether the _multi variants were useful for arm32 previously (e.g., stack args); I suspect the rest of the ABI machinery should work without this though, so let's clean up and cross other bridges later :-)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
gen_spillandgen_reloadmethods onCalleeare used to emit appropriate moves between registers and the stack, as directed by the register allocator.These moves always apply to a single register at a time, even if that register was originally part of a group of registers. For example, when an I128 is represented using two 64-bit registers, either of those registers may be spilled independently.
As a result, the
load_spillslot/store_spillslothelpers were more general than necessary, which in turn required extra complexity in thegen_load_stack_multi/gen_store_stack_multihelpers. None of these helpers were used in any other context, so all that complexity was unnecessary.Inlining all four helpers and then simplifying eliminates a lot of code without changing the output of the compiler.
These helpers were also the only uses of
StackAMode::offset, so I've deleted that. While I was there, I also deletedStackAMode::get_type, which was introduced in #8151 and became unused again in #8246.