Skip to content

Commit 0f5c6ea

Browse files
committed
Make ArgAbi::make_indirect_force more specific
1 parent 5aea140 commit 0f5c6ea

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

compiler/rustc_target/src/abi/call/mod.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
642642
pub fn make_indirect(&mut self) {
643643
match self.mode {
644644
PassMode::Direct(_) | PassMode::Pair(_, _) => {
645-
self.make_indirect_force();
645+
self.mode = Self::indirect_pass_mode(&self.layout);
646646
}
647647
PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false } => {
648648
// already indirect
@@ -652,9 +652,19 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
652652
}
653653
}
654654

655-
/// Same as make_indirect, but doesn't check the current `PassMode`.
656-
pub fn make_indirect_force(&mut self) {
657-
self.mode = Self::indirect_pass_mode(&self.layout);
655+
/// Same as `make_indirect`, but for arguments that are ignored. Only needed for ABIs that pass
656+
/// ZSTs indirectly.
657+
pub fn make_indirect_from_ignore(&mut self) {
658+
match self.mode {
659+
PassMode::Ignore => {
660+
self.mode = Self::indirect_pass_mode(&self.layout);
661+
}
662+
PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false } => {
663+
// already indirect
664+
return;
665+
}
666+
_ => panic!("Tried to make {:?} indirect (expected `PassMode::Ignore`)", self.mode),
667+
}
658668
}
659669

660670
/// Pass this argument indirectly, by placing it at a fixed stack offset.

compiler/rustc_target/src/abi/call/powerpc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn classify_arg<Ty>(cx: &impl HasTargetSpec, arg: &mut ArgAbi<'_, Ty>) {
1616
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
1717
&& arg.layout.is_zst()
1818
{
19-
arg.make_indirect_force();
19+
arg.make_indirect_from_ignore();
2020
}
2121
return;
2222
}

compiler/rustc_target/src/abi/call/s390x.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
2929
&& arg.layout.is_zst()
3030
{
31-
arg.make_indirect_force();
31+
arg.make_indirect_from_ignore();
3232
}
3333
return;
3434
}

compiler/rustc_target/src/abi/call/sparc64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ where
225225
&& matches!(&*cx.target_spec().env, "gnu" | "musl" | "uclibc")
226226
&& arg.layout.is_zst()
227227
{
228-
arg.make_indirect_force();
228+
arg.make_indirect_from_ignore();
229229
}
230230
return;
231231
}

compiler/rustc_target/src/abi/call/x86_win64.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>)
4343
&& cx.target_spec().env == "gnu"
4444
&& arg.layout.is_zst()
4545
{
46-
arg.make_indirect_force();
46+
arg.make_indirect_from_ignore();
4747
}
4848
continue;
4949
}

0 commit comments

Comments
 (0)