summary refs log tree commit diff
path: root/compiler/rustc_ty_utils/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2023-11-01 23:01:53 +0100
committerRalf Jung <post@ralfj.de>2023-11-03 07:14:27 +0100
commiteaaa03faf77b157907894a4207d8378ecaec7b45 (patch)
tree59d0b629abb77142e2a7dd711f45976045f76583 /compiler/rustc_ty_utils/src
parent405e4204d0fb7ec10ea10434fb99bcacd0324b13 (diff)
downloadrust-eaaa03faf77b157907894a4207d8378ecaec7b45.tar.gz
rust-eaaa03faf77b157907894a4207d8378ecaec7b45.zip
default Aggregate ABI to Indirect, and make sure it's never used for unsized
Diffstat (limited to 'compiler/rustc_ty_utils/src')
-rw-r--r--compiler/rustc_ty_utils/src/abi.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs
index 7c044efdc0a..0db9c5a24a8 100644
--- a/compiler/rustc_ty_utils/src/abi.rs
+++ b/compiler/rustc_ty_utils/src/abi.rs
@@ -591,13 +591,14 @@ fn fn_abi_adjust_for_abi<'tcx>(
 
                 _ => return,
             }
-            // `Aggregate` ABI must be adjusted to ensure that ABI-compatible Rust types are passed
-            // the same way.
+            // Compute `Aggregate` ABI.
+
+            let is_indirect_not_on_stack =
+                matches!(arg.mode, PassMode::Indirect { on_stack: false, .. });
+            assert!(is_indirect_not_on_stack, "{:?}", arg);
 
             let size = arg.layout.size;
-            if arg.layout.is_unsized() || size > Pointer(AddressSpace::DATA).size(cx) {
-                arg.make_indirect();
-            } else {
+            if !arg.layout.is_unsized() && size <= Pointer(AddressSpace::DATA).size(cx) {
                 // We want to pass small aggregates as immediates, but using
                 // an LLVM aggregate type for this leads to bad optimizations,
                 // so we pick an appropriately sized integer type instead.