Rollup merge of #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 https://github.com/rust-lang/rust/pull/125854#discussion_r1721047899. r? ``@RalfJung``
This commit is contained in:
commit
be80216d2c
@ -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
|
||||
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user