Repository navigation
Conversation
Collaborator
Collaborator
|
r? @oli-obk rustbot has assigned @oli-obk. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
WaffleLapkin
approved these changes
Dec 4, 2026
Comment on lines
+154
to
+156
| /// Sometimes an ABI requires small integers to be extended to a full or partial register. This | ||
| /// struct defines if this extension should be zero-extension or sign-extension when necessary. | ||
| /// When it is not necessary to extend the argument, this information is ignored. |
Member
There was a problem hiding this comment.
Not sure I understand what this is trying to say with "information is ignored"; shouldn't it just not be present when not necessary?
| /// Whether the receiver should assume that the incoming value is extended. If false, the | ||
| /// value is only extended by the sender, without an assumption on the receiver side. | ||
| /// Currently only supported for arguments. | ||
| pub with_assumption: bool, |
Member
There was a problem hiding this comment.
Could you maybe link to the reason this is needed?
Comment on lines
317
to
323
| } else { | ||
| // The x86_64 psABI requires bools to be zero-extended to 8 bits, with high | ||
| // bits unspecified. zeroext i1 has this behavior in the LLVM X86 backend. | ||
| if arg.layout.backend_repr.is_bool() { | ||
| arg.extend_integer_width_to(8); | ||
| } | ||
| } |
Member
There was a problem hiding this comment.
Suggested change
| } else { | |
| // The x86_64 psABI requires bools to be zero-extended to 8 bits, with high | |
| // bits unspecified. zeroext i1 has this behavior in the LLVM X86 backend. | |
| if arg.layout.backend_repr.is_bool() { | |
| arg.extend_integer_width_to(8); | |
| } | |
| } | |
| } else if arg.layout.backend_repr.is_bool() { | |
| // The x86_64 psABI requires bools to be zero-extended to 8 bits, with high | |
| // bits unspecified. zeroext i1 has this behavior in the LLVM X86 backend. | |
| arg.extend_integer_width_to(8); | |
| } |
This comment has been minimized.
This comment has been minimized.
This mirrors llvm/llvm-project#236450 to Rust. For non-Darwin, non-Win64 x86, the platform psABI does not require extension for small integer arguments (except bool to 8 bits). However, Clang prior to version 24 extended such arguments and assumed the extension to be present in the callee. Clang 24 switches to an asymmetric scheme, where the argument is extended at the call-site, but no extension assumed in the callee. This makes it compatible with both old Clang and the platform psABI. This PR implements the same in Rust. The Clang change comes with an `-msmall-int-abi-compat` flag to control the extension behavior. In Rust, we only support the maximally-compatible behavior. This only affects the C ABI, not the Rust ABI, so I don't think there is a need to expose more optimized ABI flavors here.
This branch has not been deployed
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.
This mirrors llvm/llvm-project#236450 to Rust.
For non-Darwin, non-Win64 x86, the platform psABI does not require extension for small integer arguments (except bool to 8 bits). However, Clang prior to version 24 extended such arguments and assumed the extension to be present in the callee.
Clang 24 switches to an asymmetric scheme, where the argument is extended at the call-site, but no extension assumed in the callee. This makes it compatible with both old Clang and the platform psABI. This PR implements the same in Rust.
The Clang change comes with an
-msmall-int-abi-compatflag to control the extension behavior. In Rust, we only support the maximally-compatible behavior. This only affects the C ABI, not the Rust ABI, so I don't think there is a need to expose more optimized ABI flavors here.