about summary refs log tree commit diff
path: root/compiler/rustc_target/src/abi
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-09-07 16:48:02 +0200
committerRalf Jung <post@ralfj.de>2023-09-08 09:14:07 +0200
commitb0cf4c28ea0f2ac0a7c6fb5bc3ee4291b7595c24 (patch)
treefe150f7773945f3ccc4304fb79532802abc71a5b /compiler/rustc_target/src/abi
parent28d152935e5f62ecbb6d2c99865de39c1993189b (diff)
downloadrust-b0cf4c28ea0f2ac0a7c6fb5bc3ee4291b7595c24.tar.gz
rust-b0cf4c28ea0f2ac0a7c6fb5bc3ee4291b7595c24.zip
turns out Layout has some more things to worry about -- move ABI comparison into helper function
like is_bool, and some special magic extra fields
Diffstat (limited to 'compiler/rustc_target/src/abi')
-rw-r--r--compiler/rustc_target/src/abi/call/mod.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs
index d4619bb6753..5d75974279e 100644
--- a/compiler/rustc_target/src/abi/call/mod.rs
+++ b/compiler/rustc_target/src/abi/call/mod.rs
@@ -60,7 +60,8 @@ pub enum PassMode {
 
 impl PassMode {
     /// Checks if these two `PassMode` are equal enough to be considered "the same for all
-    /// function call ABIs".
+    /// function call ABIs". However, the `Layout` can also impact ABI decisions,
+    /// so that needs to be compared as well!
     pub fn eq_abi(&self, other: &Self) -> bool {
         match (self, other) {
             (PassMode::Ignore, PassMode::Ignore) => true, // can still be reached for the return type
@@ -623,6 +624,14 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
     pub fn is_ignore(&self) -> bool {
         matches!(self.mode, PassMode::Ignore)
     }
+
+    /// Checks if these two `ArgAbi` are equal enough to be considered "the same for all
+    /// function call ABIs".
+    pub fn eq_abi(&self, other: &Self) -> bool {
+        // Ideally we'd just compare the `mode`, but that is not enough -- for some modes LLVM will look
+        // at the type.
+        self.layout.eq_abi(&other.layout) && self.mode.eq_abi(&other.mode)
+    }
 }
 
 #[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, HashStable_Generic)]