winch(aarch64): Improve addressing modes#12708
Open
saulecabrera wants to merge 1 commit intobytecodealliance:mainfrom
Open
winch(aarch64): Improve addressing modes#12708saulecabrera wants to merge 1 commit intobytecodealliance:mainfrom
saulecabrera wants to merge 1 commit intobytecodealliance:mainfrom
Conversation
Prior to this commit, Winch's `Address` representation relied on the general `(reg, offset)` form for offset-based addressing, leaving the materialization of the addressing mode to Cranelift. This approach led to the following bug found by the fuzzer: When offsets cannot be encoded as a 9-bit signed immediate offset or a 12-bit unsigned immediate offset with scaling, the offset must be loaded into a register and the addressing mode is transformed to its `(reg, reg)` form. Cranelift's addressing mode materialization currently uses `x16` as a scratch register to load the offset; even though both Cranelift and Winch use `x16` as a scratch register, its usage is not in sync, therefore clobbers can happen. This commit improves addressing modes by requiring early materialization of addressing modes into their respective Cranelift variants.
saulecabrera
commented
Mar 3, 2026
Comment on lines
+324
to
+325
| let constant = self.add_constant(&imm.to_bytes()); | ||
| let addr = AMode::Const { addr: constant }; |
Member
Author
There was a problem hiding this comment.
I removed this from the top-level Address since it's only used here, which removes one level of indirection.
Subscribe to Label ActionDetailsThis issue or pull request has been labeled: "winch"Thus the following users have been cc'd because of the following labels:
To subscribe or unsubscribe from this label, edit the |
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.
Prior to this commit, Winch's
Addressrepresentation relied on the general(reg, offset)form for offset-based addressing, leaving the materialization of the addressing mode to Cranelift. This approach led to the following bug found by the fuzzer:When offsets cannot be encoded as a 9-bit signed immediate offset or a 12-bit unsigned immediate offset with scaling, the offset must be loaded into a register and the addressing mode is transformed to its
(reg, reg)form. Cranelift's addressing mode materialization currently usesx16as a scratch register to load the offset; even though both Cranelift and Winch usex16as a scratch register, its usage is not in sync, therefore clobbers can happen.This commit improves addressing modes by requiring early materialization of addressing modes into their respective Cranelift variants.