-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add #[rustc_pass_indirectly_in_non_rustic_abis]
#144529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
r? @SparrowLii rustbot has assigned @SparrowLii. Use |
Some changes occurred in compiler/rustc_attr_data_structures Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
where | ||
Ty: TyAbiInterface<'a, C> + Copy, | ||
C: HasDataLayout, | ||
{ | ||
if arg.layout.pass_indirectly_in_non_rustic_abis(cx) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we rely on every single callconv getting this right, we're toast. It's way too easy to forget this somewhere.
Is there some way we can do this centrally for all ABIs?
For instance, we could apply this logic after the target-specific ABI stuff has been done.
Cc @workingjubilee
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The individual calling conventions sometimes still need to be aware of the parameters, to update the number of remaining general-purpose registers, and the current design of the calling convention code makes it hard to abstract this. Separately from this PR, I've been planning to refactor the calling convention handling a bit as even without this change there's a lot of code duplication already (all the compute_abi_info
functions are essentially variants of the same function with calls to classify_arg
and classify_ret
); this refactoring should make it possible to do this in a more centralised way.
For now, this PR previously had a cfg!(debug_assertions)
-guarded check at the end of adjust_for_foreign_abi
in callconv/mod.rs
that asserts that individual calling convention correctly set all the #[rustc_pass_indirectly_in_non_rustic_abis]
arguments to be passed indirectly. I've updated the check so it now always run rather than just running when debug_assetions
are enabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The individual calling conventions sometimes still need to be aware of the parameters, to update the number of remaining general-purpose registers,
Urgh, right, I forgot we need to care about low-level nonsense like that here. :/
Regarding refactoring the ABI code, also see #119183. I think @workingjubilee also has some thoughts in that direction. I'm happy to discuss design options and provide feedback.
c0357c1
to
61196cb
Compare
@jdonszelmann could you have a look at the attribute code here? This is my first time actually seeing the new infrastructure so I can't say if the way it is used here is correct. |
This PR adds an internal
#[rustc_pass_indirectly_in_non_rustic_abis]
attribute that can be applied to structs. Structs marked with this attribute will always be passed usingPassMode::Indirect { on_stack: false, .. }
when being passed by value to functions with non-Rustic calling conventions. This is needed by #141980; see that PR for further details.cc @joshtriplett