-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Move ZST ABI handling to rustc_target
#125854
Conversation
Some changes occurred in src/tools/compiletest cc @jieyouxu |
☔ The latest upstream changes (presumably #124733) made this pull request unmergeable. Please resolve the merge conflicts. |
r=me after rebase |
☔ The latest upstream changes (presumably #128435) made this pull request unmergeable. Please resolve the merge conflicts. |
I've rebased to fix the merge conflict. |
Friendly ping @estebank: I think this can be r+'d now that I've rebased it (I don't have r+ permissions myself). |
@bors r=estebank |
@@ -652,6 +652,11 @@ impl<'a, Ty> ArgAbi<'a, Ty> { | |||
} | |||
} | |||
|
|||
/// Same as make_indirect, but doesn't check the current `PassMode`. |
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.
Would be good to give some kind of guidance when it is okay to use this. Presumably make_indirect
has these checks for a reason?
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.
Since this is only needed for making ignored ZSTs indirect (a specific niche use-case), I've made the method more specific. Since this PR has already merged, I've submitted the changes as #129339.
// sparc64-unknown-linux-{gnu,musl,uclibc} doesn't ignore ZSTs. | ||
if cx.target_spec().os == "linux" | ||
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc") | ||
&& arg.layout.is_zst() |
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.
This treats all ZST the same, no matter their alignment. So for instance [u32; 0]
is also a ZST, but it has alignment 4. To only catch types like ()
, we have is_1zst
.
Is catching even aligned ZST the right thing here?
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.
Clang/GCC pass ZSTs indirectly on these targets regardless of alignment.
Move ZST ABI handling to `rustc_target` Currently, target specific handling of ZST function call ABI (specifically passing them indirectly instead of ignoring them) is handled in `rustc_ty_utils`, whereas all other target specific function call ABI handling is located in `rustc_target`. This PR moves the ZST handling to `rustc_target` so that all the target-specific function call ABI handling is in one place. In the process of doing so, this PR fixes rust-lang#125850 by ensuring that ZST arguments are always correctly ignored in the x86-64 `"sysv64"` ABI; any code which would be affected by this fix would have ICEd before this PR. Tests are also added using `#[rustc_abi(debug)]` to ensure this behaviour does not regress. Fixes rust-lang#125850
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#125854 (Move ZST ABI handling to `rustc_target`) - rust-lang#127623 (fix: fs::remove_dir_all: treat internal ENOENT as success) - rust-lang#128084 (Suggest adding Result return type for associated method in E0277.) - rust-lang#128902 (doc: std::env::var: Returns None for names with '=' or NUL byte) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation) - rust-lang#129235 (Check that `#[may_dangle]` is properly applied) - rust-lang#129245 (Typo) r? `@ghost` `@rustbot` modify labels: rollup
☀️ Test successful - checks-actions |
Finished benchmarking commit (d0293c6): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results (secondary 1.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 1.9%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 751.033s -> 751.219s (0.02%) |
…, r=RalfJung Make `ArgAbi::make_indirect_force` more specific As the method is only needed for making ignored ZSTs indirect on some ABIs, rename and add a doc-comment and `self.mode` check to make it harder to accidentally misuse. Addresses review feedback from rust-lang#125854 (comment). r? `@RalfJung`
…, r=RalfJung Make `ArgAbi::make_indirect_force` more specific As the method is only needed for making ignored ZSTs indirect on some ABIs, rename and add a doc-comment and `self.mode` check to make it harder to accidentally misuse. Addresses review feedback from rust-lang#125854 (comment). r? ``@RalfJung``
Rollup merge of rust-lang#129339 - beetrees:make-indirect-from-ignore, r=RalfJung Make `ArgAbi::make_indirect_force` more specific As the method is only needed for making ignored ZSTs indirect on some ABIs, rename and add a doc-comment and `self.mode` check to make it harder to accidentally misuse. Addresses review feedback from rust-lang#125854 (comment). r? ``@RalfJung``
Currently, target specific handling of ZST function call ABI (specifically passing them indirectly instead of ignoring them) is handled in
rustc_ty_utils
, whereas all other target specific function call ABI handling is located inrustc_target
. This PR moves the ZST handling torustc_target
so that all the target-specific function call ABI handling is in one place. In the process of doing so, this PR fixes #125850 by ensuring that ZST arguments are always correctly ignored in the x86-64"sysv64"
ABI; any code which would be affected by this fix would have ICEd before this PR. Tests are also added using#[rustc_abi(debug)]
to ensure this behaviour does not regress.Fixes #125850