about summary refs log tree commit diff
path: root/compiler/rustc_target/src/abi/call/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_target/src/abi/call/mod.rs')
-rw-r--r--compiler/rustc_target/src/abi/call/mod.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs
index 25e4d70945b..c1ddfcb2f90 100644
--- a/compiler/rustc_target/src/abi/call/mod.rs
+++ b/compiler/rustc_target/src/abi/call/mod.rs
@@ -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.