Skip to content
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

Make ArgAbi::make_indirect_force more specific #129339

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions compiler/rustc_target/src/abi/call/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
pub fn make_indirect(&mut self) {
match self.mode {
PassMode::Direct(_) | PassMode::Pair(_, _) => {
self.make_indirect_force();
self.mode = Self::indirect_pass_mode(&self.layout);
}
PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false } => {
// already indirect
Expand All @@ -652,9 +652,19 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
}
}

/// Same as make_indirect, but doesn't check the current `PassMode`.
pub fn make_indirect_force(&mut self) {
self.mode = Self::indirect_pass_mode(&self.layout);
/// Same as `make_indirect`, but for arguments that are ignored. Only needed for ABIs that pass
/// ZSTs indirectly.
pub fn make_indirect_from_ignore(&mut self) {
match self.mode {
PassMode::Ignore => {
self.mode = Self::indirect_pass_mode(&self.layout);
}
PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false } => {
// already indirect
return;
}
_ => panic!("Tried to make {:?} indirect (expected `PassMode::Ignore`)", self.mode),
}
}

/// Pass this argument indirectly, by placing it at a fixed stack offset.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/call/powerpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn classify_arg<Ty>(cx: &impl HasTargetSpec, arg: &mut ArgAbi<'_, Ty>) {
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
&& arg.layout.is_zst()
{
arg.make_indirect_force();
arg.make_indirect_from_ignore();
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/call/s390x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ where
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
&& arg.layout.is_zst()
{
arg.make_indirect_force();
arg.make_indirect_from_ignore();
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/call/sparc64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ where
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
&& arg.layout.is_zst()
{
arg.make_indirect_force();
arg.make_indirect_from_ignore();
}
return;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/abi/call/x86_win64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>)
&& cx.target_spec().env == "gnu"
&& arg.layout.is_zst()
{
arg.make_indirect_force();
arg.make_indirect_from_ignore();
}
continue;
}
Expand Down
Loading