]> git.proxmox.com Git - rustc.git/blame - debian/patches/0001-Revert-Auto-merge-of-79547.patch
refresh all patches, make diff markings consistent
[rustc.git] / debian / patches / 0001-Revert-Auto-merge-of-79547.patch
CommitLineData
ca32d9a7
XL
1From eaf7ea1fc339e1ff348ed941ed2e8c4d66f3e458 Mon Sep 17 00:00:00 2001
2From: Josh Stone <jistone@redhat.com>
3Date: Thu, 18 Feb 2021 19:14:58 -0800
4Subject: [PATCH] Revert "Auto merge of #79547 - erikdesjardins:byval, r=nagisa"
5
6This reverts commit a094ff9590b83c8f94d898f92c2964a5803ded06, reversing
7changes made to d37afad0cc87bf709ad10c85319296ac53030f03.
8
9See https://github.com/rust-lang/rust/issues/80810 for more background
10---
11 compiler/rustc_middle/src/ty/layout.rs | 12 ++++++------
12 ...return-value-in-reg.rs => return-value-in-reg.rs} | 4 ++--
13 src/test/codegen/union-abi.rs | 11 +++--------
14 3 files changed, 11 insertions(+), 16 deletions(-)
15 rename src/test/codegen/{arg-return-value-in-reg.rs => return-value-in-reg.rs} (74%)
16
ca32d9a7
XL
17--- a/compiler/rustc_middle/src/ty/layout.rs
18+++ b/compiler/rustc_middle/src/ty/layout.rs
cefde48f 19@@ -2863,7 +2863,7 @@
ca32d9a7
XL
20 || abi == SpecAbi::RustIntrinsic
21 || abi == SpecAbi::PlatformIntrinsic
22 {
23- let fixup = |arg: &mut ArgAbi<'tcx, Ty<'tcx>>| {
24+ let fixup = |arg: &mut ArgAbi<'tcx, Ty<'tcx>>, is_ret: bool| {
25 if arg.is_ignore() {
26 return;
27 }
cefde48f 28@@ -2901,9 +2901,9 @@
ca32d9a7
XL
29 _ => return,
30 }
31
32- // Pass and return structures up to 2 pointers in size by value, matching `ScalarPair`.
33- // LLVM will usually pass these in 2 registers, which is more efficient than by-ref.
34- let max_by_val_size = Pointer.size(cx) * 2;
35+ // Return structures up to 2 pointers in size by value, matching `ScalarPair`. LLVM
36+ // will usually return these in 2 registers, which is more efficient than by-ref.
37+ let max_by_val_size = if is_ret { Pointer.size(cx) * 2 } else { Pointer.size(cx) };
38 let size = arg.layout.size;
39
40 if arg.layout.is_unsized() || size > max_by_val_size {
cefde48f 41@@ -2915,9 +2915,9 @@
ca32d9a7
XL
42 arg.cast_to(Reg { kind: RegKind::Integer, size });
43 }
44 };
45- fixup(&mut self.ret);
46+ fixup(&mut self.ret, true);
47 for arg in &mut self.args {
48- fixup(arg);
49+ fixup(arg, false);
50 }
51 return;
52 }
ca32d9a7 53--- a/src/test/codegen/arg-return-value-in-reg.rs
cefde48f
XL
54+++ /dev/null
55@@ -1,32 +0,0 @@
ca32d9a7 56-//! Check that types of up to 128 bits are passed and returned by-value instead of via pointer.
cefde48f
XL
57-
58-// compile-flags: -C no-prepopulate-passes -O
59-// only-x86_64
60-
61-#![crate_type = "lib"]
62-
63-pub struct S {
64- a: u64,
65- b: u32,
66- c: u32,
67-}
68-
ca32d9a7 69-// CHECK: define i128 @modify(i128{{( %0)?}})
cefde48f
XL
70-#[no_mangle]
71-pub fn modify(s: S) -> S {
72- S { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c }
73-}
74-
75-#[repr(packed)]
76-pub struct TooBig {
77- a: u64,
78- b: u32,
79- c: u32,
80- d: u8,
81-}
82-
83-// CHECK: define void @m_big(%TooBig* [[ATTRS:.*sret.*]], %TooBig* [[ATTRS2:.*]] %s)
84-#[no_mangle]
85-pub fn m_big(s: TooBig) -> TooBig {
86- TooBig { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c, d: s.d + s.d }
87-}
88--- /dev/null
89+++ b/src/test/codegen/return-value-in-reg.rs
90@@ -0,0 +1,32 @@
91+//! This test checks that types of up to 128 bits are returned by-value instead of via out-pointer.
92+
93+// compile-flags: -C no-prepopulate-passes -O
94+// only-x86_64
95+
96+#![crate_type = "lib"]
97+
98+pub struct S {
99+ a: u64,
100+ b: u32,
101+ c: u32,
102+}
103+
ca32d9a7 104+// CHECK: define i128 @modify(%S* noalias nocapture dereferenceable(16) %s)
cefde48f
XL
105+#[no_mangle]
106+pub fn modify(s: S) -> S {
107+ S { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c }
108+}
109+
110+#[repr(packed)]
111+pub struct TooBig {
112+ a: u64,
113+ b: u32,
114+ c: u32,
115+ d: u8,
116+}
117+
118+// CHECK: define void @m_big(%TooBig* [[ATTRS:.*sret.*]], %TooBig* [[ATTRS2:.*]] %s)
119+#[no_mangle]
120+pub fn m_big(s: TooBig) -> TooBig {
121+ TooBig { a: s.a + s.a, b: s.b + s.b, c: s.c + s.c, d: s.d + s.d }
122+}
ca32d9a7
XL
123--- a/src/test/codegen/union-abi.rs
124+++ b/src/test/codegen/union-abi.rs
cefde48f 125@@ -63,16 +63,11 @@
ca32d9a7
XL
126 #[no_mangle]
127 pub fn test_UnionU128(_: UnionU128) -> UnionU128 { loop {} }
128
129-pub union UnionU128x2{a:(u128, u128)}
130-// CHECK: define void @test_UnionU128x2(i128 %_1.0, i128 %_1.1)
131-#[no_mangle]
132-pub fn test_UnionU128x2(_: UnionU128x2) { loop {} }
133-
134 #[repr(C)]
135-pub union CUnionU128x2{a:(u128, u128)}
136-// CHECK: define void @test_CUnionU128x2(%CUnionU128x2* {{.*}} %_1)
137+pub union CUnionU128{a:u128}
138+// CHECK: define void @test_CUnionU128(%CUnionU128* {{.*}} %_1)
139 #[no_mangle]
140-pub fn test_CUnionU128x2(_: CUnionU128x2) { loop {} }
141+pub fn test_CUnionU128(_: CUnionU128) { loop {} }
142
143 pub union UnionBool { b:bool }
144 // CHECK: define zeroext i1 @test_UnionBool(i8 %b)