about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVin Singh <theshampoofactory@gmail.com>2021-12-08 12:01:13 +0000
committerVin Singh <theshampoofactory@gmail.com>2022-03-03 18:30:27 +0000
commit9d45e0e0b4593b824917bfae71e5161973eb7a11 (patch)
treee4b912aecdd32ebfcd529c4b02f6d27c87bd8c35
parentf0c4da49983aa699f715caf681e3154b445fb60b (diff)
downloadrust-9d45e0e0b4593b824917bfae71e5161973eb7a11.tar.gz
rust-9d45e0e0b4593b824917bfae71e5161973eb7a11.zip
Revert #26494 regression
-rw-r--r--compiler/rustc_middle/src/ty/layout.rs6
-rw-r--r--src/test/codegen/arg-return-value-in-reg.rs32
-rw-r--r--src/test/codegen/array-equality.rs1
-rw-r--r--src/test/codegen/union-abi.rs11
4 files changed, 5 insertions, 45 deletions
diff --git a/compiler/rustc_middle/src/ty/layout.rs b/compiler/rustc_middle/src/ty/layout.rs
index c77047f8a2e..7495449da4c 100644
--- a/compiler/rustc_middle/src/ty/layout.rs
+++ b/compiler/rustc_middle/src/ty/layout.rs
@@ -3226,12 +3226,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
                     _ => return,
                 }
 
-                // Pass and return structures up to 2 pointers in size by value, matching `ScalarPair`.
-                // LLVM will usually pass these in 2 registers, which is more efficient than by-ref.
-                let max_by_val_size = Pointer.size(self) * 2;
                 let size = arg.layout.size;
-
-                if arg.layout.is_unsized() || size > max_by_val_size {
+                if arg.layout.is_unsized() || size > Pointer.size(self) {
                     arg.make_indirect();
                 } else {
                     // We want to pass small aggregates as immediates, but using
diff --git a/src/test/codegen/arg-return-value-in-reg.rs b/src/test/codegen/arg-return-value-in-reg.rs
deleted file mode 100644
index a69291d4782..00000000000
--- a/src/test/codegen/arg-return-value-in-reg.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-//! Check that types of up to 128 bits are passed and returned by-value instead of via pointer.
-
-// compile-flags: -C no-prepopulate-passes -O
-// only-x86_64
-
-#![crate_type = "lib"]
-
-pub struct S {
-    a: u64,
-    b: u32,
-    c: u32,
-}
-
-// CHECK: define i128 @modify(i128{{( %0)?}})
-#[no_mangle]
-pub fn modify(s: S) -> S {
-    S { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c }
-}
-
-#[repr(packed)]
-pub struct TooBig {
-    a: u64,
-    b: u32,
-    c: u32,
-    d: u8,
-}
-
-// CHECK: define void @m_big(%TooBig* [[ATTRS:.*sret.*]], %TooBig* [[ATTRS2:.*]] %s)
-#[no_mangle]
-pub fn m_big(s: TooBig) -> TooBig {
-    TooBig { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c, d: s.d + s.d }
-}
diff --git a/src/test/codegen/array-equality.rs b/src/test/codegen/array-equality.rs
index fefc232b490..c6b57ee5429 100644
--- a/src/test/codegen/array-equality.rs
+++ b/src/test/codegen/array-equality.rs
@@ -1,5 +1,6 @@
 // compile-flags: -O
 // only-x86_64
+// ignore-test will need to be rewritten if pull accepted
 
 #![crate_type = "lib"]
 
diff --git a/src/test/codegen/union-abi.rs b/src/test/codegen/union-abi.rs
index 99576a5f57e..01f917b2910 100644
--- a/src/test/codegen/union-abi.rs
+++ b/src/test/codegen/union-abi.rs
@@ -63,16 +63,11 @@ pub union UnionU128{a:u128}
 #[no_mangle]
 pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} }
 
-pub union UnionU128x2{a:(u128, u128)}
-// CHECK: define void @test_UnionU128x2(i128 %_1.0, i128 %_1.1)
-#[no_mangle]
-pub fn test_UnionU128x2(_: UnionU128x2) { loop {} }
-
 #[repr(C)]
-pub union CUnionU128x2{a:(u128, u128)}
-// CHECK: define void @test_CUnionU128x2(%CUnionU128x2* {{.*}} %_1)
+pub union CUnionU128{a:u128}
+// CHECK: define void @test_CUnionU128(%CUnionU128* {{.*}} %_1)
 #[no_mangle]
-pub fn test_CUnionU128x2(_: CUnionU128x2) { loop {} }
+pub fn test_CUnionU128(_: CUnionU128) { loop {} }
 
 pub union UnionBool { b:bool }
 // CHECK: define noundef zeroext i1 @test_UnionBool(i8 %b)