Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / 64bit-swiftcall.c
blobda6f18248c2af29bb5f96b86fc603a4febc41929
1 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-apple-darwin10 -target-cpu core2 -emit-llvm -o - %s | FileCheck %s --check-prefix=X86-64
3 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple arm64-apple-ios9 -target-cpu cyclone -emit-llvm -o - %s | FileCheck %s --check-prefix=ARM64
6 // REQUIRES: aarch64-registered-target,x86-registered-target
8 #define SWIFTCALL __attribute__((swiftcall))
9 #define SWIFTASYNCCALL __attribute__((swiftasynccall))
10 #define OUT __attribute__((swift_indirect_result))
11 #define ERROR __attribute__((swift_error_result))
12 #define CONTEXT __attribute__((swift_context))
13 #define ASYNC_CONTEXT __attribute__((swift_async_context))
15 // CHECK-DAG: %struct.atomic_padded = type { { %struct.packed, [7 x i8] } }
16 // CHECK-DAG: %struct.packed = type <{ i64, i8 }>
18 // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 }
20 /*****************************************************************************/
21 /****************************** PARAMETER ABIS *******************************/
22 /*****************************************************************************/
24 SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {}
25 // CHECK-LABEL: define {{.*}} void @indirect_result_1(ptr noalias sret(ptr) align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}})
27 // TODO: maybe this shouldn't suppress sret.
28 SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); }
29 // CHECK-LABEL: define {{.*}} i32 @indirect_result_2(ptr noalias align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}})
31 typedef struct { char array[1024]; } struct_reallybig;
32 SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); }
33 // CHECK-LABEL: define {{.*}} void @indirect_result_3(ptr noalias sret(%struct.struct_reallybig) {{.*}}, ptr noalias align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}})
35 SWIFTCALL void context_1(CONTEXT void *self) {}
36 // CHECK-LABEL: define {{.*}} void @context_1(ptr swiftself
38 SWIFTASYNCCALL void async_context_1(ASYNC_CONTEXT void *ctx) {}
39 // CHECK-LABEL: define {{.*}} void @async_context_1(ptr swiftasync
41 SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {}
42 // CHECK-LABEL: define {{.*}} void @context_2(ptr{{.*}}, ptr swiftself
44 SWIFTASYNCCALL void async_context_2(void *arg0, ASYNC_CONTEXT void *ctx) {}
45 // CHECK-LABEL: define {{.*}} void @async_context_2(ptr{{.*}}, ptr swiftasync
47 SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {}
48 // CHECK-LABEL: define {{.*}} void @context_error_1(ptr swiftself{{.*}}, ptr swifterror %0)
49 // CHECK: [[TEMP:%.*]] = alloca ptr, align 8
50 // CHECK: [[T0:%.*]] = load ptr, ptr [[ERRORARG:%.*]], align 8
51 // CHECK: store ptr [[T0]], ptr [[TEMP]], align 8
52 // CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 8
53 // CHECK: store ptr [[T0]], ptr [[ERRORARG]], align 8
54 void test_context_error_1() {
55 int x;
56 float *error;
57 context_error_1(&x, &error);
59 // CHECK-LABEL: define{{.*}} void @test_context_error_1()
60 // CHECK: [[X:%.*]] = alloca i32, align 4
61 // CHECK: [[ERROR:%.*]] = alloca ptr, align 8
62 // CHECK: [[TEMP:%.*]] = alloca swifterror ptr, align 8
63 // CHECK: [[T0:%.*]] = load ptr, ptr [[ERROR]], align 8
64 // CHECK: store ptr [[T0]], ptr [[TEMP]], align 8
65 // CHECK: call [[SWIFTCC:swiftcc]] void @context_error_1(ptr swiftself [[X]], ptr swifterror [[TEMP]])
66 // CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 8
67 // CHECK: store ptr [[T0]], ptr [[ERROR]], align 8
69 SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float **error) {}
70 // CHECK-LABEL: define {{.*}} void @context_error_2(i16{{.*}}, ptr swiftself{{.*}}, ptr swifterror %0)
72 /*****************************************************************************/
73 /********************************** LOWERING *********************************/
74 /*****************************************************************************/
76 typedef float float3 __attribute__((ext_vector_type(3)));
77 typedef float float4 __attribute__((ext_vector_type(4)));
78 typedef float float8 __attribute__((ext_vector_type(8)));
79 typedef double double2 __attribute__((ext_vector_type(2)));
80 typedef double double4 __attribute__((ext_vector_type(4)));
81 typedef int int3 __attribute__((ext_vector_type(3)));
82 typedef int int4 __attribute__((ext_vector_type(4)));
83 typedef int int5 __attribute__((ext_vector_type(5)));
84 typedef int int8 __attribute__((ext_vector_type(8)));
85 typedef char char16 __attribute__((ext_vector_type(16)));
86 typedef short short8 __attribute__((ext_vector_type(8)));
87 typedef long long long2 __attribute__((ext_vector_type(2)));
89 #define TEST(TYPE) \
90 SWIFTCALL TYPE return_##TYPE(void) { \
91 TYPE result = {}; \
92 return result; \
93 } \
94 SWIFTCALL void take_##TYPE(TYPE v) { \
95 } \
96 void test_##TYPE() { \
97 take_##TYPE(return_##TYPE()); \
100 /*****************************************************************************/
101 /*********************************** STRUCTS *********************************/
102 /*****************************************************************************/
104 typedef struct {
105 } struct_empty;
106 TEST(struct_empty);
107 // CHECK-LABEL: define {{.*}} @return_struct_empty()
108 // CHECK: ret void
109 // CHECK-LABEL: define {{.*}} @take_struct_empty()
110 // CHECK: ret void
112 typedef struct {
113 int x;
114 char c0;
115 char c1;
116 int f0;
117 int f1;
118 } struct_1;
119 TEST(struct_1);
120 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_1() {{.*}}{
121 // CHECK: [[RET:%.*]] = alloca [[STRUCT1:%.*]], align 4
122 // CHECK: call void @llvm.memset
123 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr %retval, i32 0, i32 0
124 // CHECK: [[T0:%.*]] = load i64, ptr [[GEP0]], align 4
125 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr %retval, i32 0, i32 1
126 // CHECK: [[T1:%.*]] = load i64, ptr [[GEP1]], align 4
127 // CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
128 // CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
129 // CHECK: ret { i64, i64 } [[R1]]
130 // CHECK: }
131 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_1(i64 %0, i64 %1) {{.*}}{
132 // CHECK: [[V:%.*]] = alloca [[STRUCT1:%.*]], align 4
133 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 0
134 // CHECK: store i64 %0, ptr [[GEP0]], align 4
135 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 1
136 // CHECK: store i64 %1, ptr [[GEP1]], align 4
137 // CHECK: ret void
138 // CHECK: }
139 // CHECK-LABEL: define{{.*}} void @test_struct_1() {{.*}}{
140 // CHECK: [[AGG:%.*]] = alloca [[STRUCT1:%.*]], align 4
141 // CHECK: [[RET:%.*]] = call swiftcc { i64, i64 } @return_struct_1()
142 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 0
143 // CHECK: [[E0:%.*]] = extractvalue { i64, i64 } [[RET]], 0
144 // CHECK: store i64 [[E0]], ptr [[GEP0]], align 4
145 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 1
146 // CHECK: [[E1:%.*]] = extractvalue { i64, i64 } [[RET]], 1
147 // CHECK: store i64 [[E1]], ptr [[GEP1]], align 4
148 // CHECK: [[GEP2:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 0
149 // CHECK: [[V0:%.*]] = load i64, ptr [[GEP2]], align 4
150 // CHECK: [[GEP3:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 1
151 // CHECK: [[V1:%.*]] = load i64, ptr [[GEP3]], align 4
152 // CHECK: call swiftcc void @take_struct_1(i64 [[V0]], i64 [[V1]])
153 // CHECK: ret void
154 // CHECK: }
156 typedef struct {
157 int x;
158 char c0;
159 __attribute__((aligned(2))) char c1;
160 int f0;
161 int f1;
162 } struct_2;
163 TEST(struct_2);
164 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_2() {{.*}}{
165 // CHECK: [[RET:%.*]] = alloca [[STRUCT2_TYPE]], align 4
166 // CHECK: call void @llvm.memcpy{{.*}}({{.*}}[[RET]], {{.*}}[[STRUCT2_RESULT]]
167 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[RET]], i32 0, i32 0
168 // CHECK: [[T0:%.*]] = load i64, ptr [[GEP0]], align 4
169 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[RET]], i32 0, i32 1
170 // CHECK: [[T1:%.*]] = load i64, ptr [[GEP1]], align 4
171 // CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
172 // CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
173 // CHECK: ret { i64, i64 } [[R1]]
174 // CHECK: }
175 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_2(i64 %0, i64 %1) {{.*}}{
176 // CHECK: [[V:%.*]] = alloca [[STRUCT:%.*]], align 4
177 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 0
178 // CHECK: store i64 %0, ptr [[GEP0]], align 4
179 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 1
180 // CHECK: store i64 %1, ptr [[GEP1]], align 4
181 // CHECK: ret void
182 // CHECK: }
183 // CHECK-LABEL: define{{.*}} void @test_struct_2() {{.*}} {
184 // CHECK: [[TMP:%.*]] = alloca [[STRUCT2_TYPE]], align 4
185 // CHECK: [[CALL:%.*]] = call swiftcc { i64, i64 } @return_struct_2()
186 // CHECK: [[GEP:%.*]] = getelementptr inbounds {{.*}} [[TMP]], i32 0, i32 0
187 // CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 0
188 // CHECK: store i64 [[T0]], ptr [[GEP]], align 4
189 // CHECK: [[GEP:%.*]] = getelementptr inbounds {{.*}} [[TMP]], i32 0, i32 1
190 // CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 1
191 // CHECK: store i64 [[T0]], ptr [[GEP]], align 4
192 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[TMP]], i32 0, i32 0
193 // CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 4
194 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[TMP]], i32 0, i32 1
195 // CHECK: [[R1:%.*]] = load i64, ptr [[GEP]], align 4
196 // CHECK: call swiftcc void @take_struct_2(i64 [[R0]], i64 [[R1]])
197 // CHECK: ret void
198 // CHECK: }
200 // There's no way to put a field randomly in the middle of an otherwise
201 // empty storage unit in C, so that case has to be tested in C++, which
202 // can use empty structs to introduce arbitrary padding. (In C, they end up
203 // with size 0 and so don't affect layout.)
205 // Misaligned data rule.
206 typedef struct {
207 char c0;
208 __attribute__((packed)) float f;
209 } struct_misaligned_1;
210 TEST(struct_misaligned_1)
211 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_misaligned_1()
212 // CHECK: [[RET:%.*]] = alloca [[STRUCT:%.*]], align 1
213 // CHECK: call void @llvm.memset{{.*}}(ptr align 1 [[RET]], i8 0, i64 5
214 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[RET]], i32 0, i32 0
215 // CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 1
216 // CHECK: ret i64 [[R0]]
217 // CHECK:}
218 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_misaligned_1(i64 %0) {{.*}}{
219 // CHECK: [[V:%.*]] = alloca [[STRUCT:%.*]], align 1
220 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[V]], i32 0, i32 0
221 // CHECK: store i64 %0, ptr [[GEP]], align 1
222 // CHECK: ret void
223 // CHECK: }
224 // CHECK: define{{.*}} void @test_struct_misaligned_1() {{.*}}{
225 // CHECK: [[AGG:%.*]] = alloca [[STRUCT:%.*]], align 1
226 // CHECK: [[CALL:%.*]] = call swiftcc i64 @return_struct_misaligned_1()
227 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
228 // CHECK: store i64 [[CALL]], ptr [[T1]], align 1
229 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
230 // CHECK: [[P:%.*]] = load i64, ptr [[T1]], align 1
231 // CHECK: call swiftcc void @take_struct_misaligned_1(i64 [[P]])
232 // CHECK: ret void
233 // CHECK: }
235 // Too many scalars.
236 typedef struct {
237 long long x[5];
238 } struct_big_1;
239 TEST(struct_big_1)
241 // CHECK-LABEL: define {{.*}} void @return_struct_big_1({{.*}} noalias sret
243 // Should not be byval.
244 // CHECK-LABEL: define {{.*}} void @take_struct_big_1(ptr{{( %.*)?}})
246 /*****************************************************************************/
247 /********************************* TYPE MERGING ******************************/
248 /*****************************************************************************/
250 typedef union {
251 float f;
252 double d;
253 } union_het_fp;
254 TEST(union_het_fp)
255 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_union_het_fp()
256 // CHECK: [[RET:%.*]] = alloca [[UNION:%.*]], align 8
257 // CHECK: call void @llvm.memcpy{{.*}}(ptr align 8 [[RET]]
258 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[RET]], i32 0, i32 0
259 // CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 8
260 // CHECK: ret i64 [[R0]]
261 // CHECK-LABEL: define{{.*}} swiftcc void @take_union_het_fp(i64 %0) {{.*}}{
262 // CHECK: [[V:%.*]] = alloca [[UNION:%.*]], align 8
263 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[V]], i32 0, i32 0
264 // CHECK: store i64 %0, ptr [[GEP]], align 8
265 // CHECK: ret void
266 // CHECK: }
267 // CHECK-LABEL: define{{.*}} void @test_union_het_fp() {{.*}}{
268 // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 8
269 // CHECK: [[CALL:%.*]] = call swiftcc i64 @return_union_het_fp()
270 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
271 // CHECK: store i64 [[CALL]], ptr [[T1]], align 8
272 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
273 // CHECK: [[V0:%.*]] = load i64, ptr [[T1]], align 8
274 // CHECK: call swiftcc void @take_union_het_fp(i64 [[V0]])
275 // CHECK: ret void
276 // CHECK: }
279 typedef union {
280 float f1;
281 float f2;
282 } union_hom_fp;
283 TEST(union_hom_fp)
284 // CHECK-LABEL: define{{.*}} void @test_union_hom_fp()
285 // CHECK: [[TMP:%.*]] = alloca [[REC:%.*]], align 4
286 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] float @return_union_hom_fp()
287 // CHECK: [[T0:%.*]] = getelementptr inbounds { float }, ptr [[TMP]], i32 0, i32 0
288 // CHECK: store float [[CALL]], ptr [[T0]], align 4
289 // CHECK: [[T0:%.*]] = getelementptr inbounds { float }, ptr [[TMP]], i32 0, i32 0
290 // CHECK: [[FIRST:%.*]] = load float, ptr [[T0]], align 4
291 // CHECK: call [[SWIFTCC]] void @take_union_hom_fp(float [[FIRST]])
292 // CHECK: ret void
294 typedef union {
295 float f1;
296 float4 fv2;
297 } union_hom_fp_partial;
298 TEST(union_hom_fp_partial)
299 // CHECK: define{{.*}} void @test_union_hom_fp_partial()
300 // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16
301 // CHECK: [[CALL:%.*]] = call swiftcc { float, float, float, float } @return_union_hom_fp_partial()
302 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 0
303 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 0
304 // CHECK: store float [[T1]], ptr [[T0]], align 16
305 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 1
306 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 1
307 // CHECK: store float [[T1]], ptr [[T0]], align 4
308 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 2
309 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 2
310 // CHECK: store float [[T1]], ptr [[T0]], align 8
311 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 3
312 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 3
313 // CHECK: store float [[T1]], ptr [[T0]], align 4
314 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 0
315 // CHECK: [[V0:%.*]] = load float, ptr [[T0]], align 16
316 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 1
317 // CHECK: [[V1:%.*]] = load float, ptr [[T0]], align 4
318 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 2
319 // CHECK: [[V2:%.*]] = load float, ptr [[T0]], align 8
320 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 3
321 // CHECK: [[V3:%.*]] = load float, ptr [[T0]], align 4
322 // CHECK: call swiftcc void @take_union_hom_fp_partial(float [[V0]], float [[V1]], float [[V2]], float [[V3]])
323 // CHECK: ret void
324 // CHECK: }
326 typedef union {
327 struct { int x, y; } f1;
328 float4 fv2;
329 } union_het_fpv_partial;
330 TEST(union_het_fpv_partial)
331 // CHECK-LABEL: define{{.*}} void @test_union_het_fpv_partial()
332 // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16
333 // CHECK: [[CALL:%.*]] = call swiftcc { i64, float, float } @return_union_het_fpv_partial()
334 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 0
335 // CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 0
336 // CHECK: store i64 [[T1]], ptr [[T0]], align 16
337 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 1
338 // CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 1
339 // CHECK: store float [[T1]], ptr [[T0]], align 8
340 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 2
341 // CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 2
342 // CHECK: store float [[T1]], ptr [[T0]], align 4
343 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 0
344 // CHECK: [[V0:%.*]] = load i64, ptr [[T0]], align 16
345 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 1
346 // CHECK: [[V1:%.*]] = load float, ptr [[T0]], align 8
347 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 2
348 // CHECK: [[V2:%.*]] = load float, ptr [[T0]], align 4
349 // CHECK: call swiftcc void @take_union_het_fpv_partial(i64 [[V0]], float [[V1]], float [[V2]])
350 // CHECK: ret void
351 // CHECK: }
353 /*****************************************************************************/
354 /****************************** VECTOR LEGALIZATION **************************/
355 /*****************************************************************************/
357 TEST(int4)
358 // CHECK-LABEL: define {{.*}} <4 x i32> @return_int4()
359 // CHECK-LABEL: define {{.*}} @take_int4(<4 x i32>
361 TEST(int8)
362 // CHECK-LABEL: define {{.*}} @return_int8()
363 // CHECK: [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 16
364 // CHECK: [[VAR:%.*]] = alloca [[REC]], align
365 // CHECK: store
366 // CHECK: load
367 // CHECK: store
368 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG:.+]], ptr [[RET]], i32 0, i32 0
369 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
370 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[RET]], i32 0, i32 1
371 // CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align
372 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, <4 x i32> [[FIRST]], 0
373 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1
374 // CHECK: ret [[UAGG]] [[T1]]
375 // CHECK-LABEL: define {{.*}} @take_int8(<4 x i32> %0, <4 x i32> %1)
376 // CHECK: [[V:%.*]] = alloca [[REC]], align
377 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 0
378 // CHECK: store <4 x i32> %0, ptr [[T0]], align
379 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 1
380 // CHECK: store <4 x i32> %1, ptr [[T0]], align
381 // CHECK: ret void
382 // CHECK-LABEL: define{{.*}} void @test_int8()
383 // CHECK: [[TMP1:%.*]] = alloca [[REC]], align
384 // CHECK: [[TMP2:%.*]] = alloca [[REC]], align
385 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int8()
386 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 0
387 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
388 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
389 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 1
390 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
391 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
392 // CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align
393 // CHECK: store [[REC]] [[V]], ptr [[TMP2]], align
394 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 0
395 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
396 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 1
397 // CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align
398 // CHECK: call [[SWIFTCC]] void @take_int8(<4 x i32> [[FIRST]], <4 x i32> [[SECOND]])
399 // CHECK: ret void
401 TEST(int5)
402 // CHECK-LABEL: define {{.*}} @return_int5()
403 // CHECK: [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 16
404 // CHECK: [[VAR:%.*]] = alloca [[REC]], align
405 // CHECK: store
406 // CHECK: load
407 // CHECK: store
408 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG:.+]], ptr [[RET]], i32 0, i32 0
409 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
410 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[RET]], i32 0, i32 1
411 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align
412 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x i32> [[FIRST]], 0
413 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
414 // CHECK: ret [[UAGG]] [[T1]]
415 // CHECK-LABEL: define {{.*}} @take_int5(<4 x i32> %0, i32 %1)
416 // CHECK: [[V:%.*]] = alloca [[REC]], align
417 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 0
418 // CHECK: store <4 x i32> %0, ptr [[T0]], align
419 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 1
420 // CHECK: store i32 %1, ptr [[T0]], align
421 // CHECK: ret void
422 // CHECK-LABEL: define{{.*}} void @test_int5()
423 // CHECK: [[TMP1:%.*]] = alloca [[REC]], align
424 // CHECK: [[TMP2:%.*]] = alloca [[REC]], align
425 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int5()
426 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 0
427 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
428 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
429 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 1
430 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
431 // CHECK: store i32 [[T1]], ptr [[T0]], align
432 // CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align
433 // CHECK: store [[REC]] [[V]], ptr [[TMP2]], align
434 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 0
435 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
436 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 1
437 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align
438 // CHECK: call [[SWIFTCC]] void @take_int5(<4 x i32> [[FIRST]], i32 [[SECOND]])
439 // CHECK: ret void
441 typedef struct {
442 int x;
443 int3 v __attribute__((packed));
444 } misaligned_int3;
445 TEST(misaligned_int3)
446 // CHECK-LABEL: define{{.*}} swiftcc void @take_misaligned_int3(i64 %0, i64 %1)
448 typedef struct {
449 float f0;
450 } struct_f1;
451 TEST(struct_f1)
452 // CHECK-LABEL: define{{.*}} swiftcc float @return_struct_f1()
453 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f1(float %0)
455 typedef struct {
456 float f0;
457 float f1;
458 } struct_f2;
459 TEST(struct_f2)
460 // CHECK-LABEL: define{{.*}} swiftcc { float, float } @return_struct_f2()
461 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f2(float %0, float %1)
463 typedef struct {
464 float f0;
465 float f1;
466 float f2;
467 } struct_f3;
468 TEST(struct_f3)
469 // CHECK-LABEL: define{{.*}} swiftcc { float, float, float } @return_struct_f3()
470 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f3(float %0, float %1, float %2)
472 typedef struct {
473 float f0;
474 float f1;
475 float f2;
476 float f3;
477 } struct_f4;
478 TEST(struct_f4)
479 // CHECK-LABEL: define{{.*}} swiftcc { float, float, float, float } @return_struct_f4()
480 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f4(float %0, float %1, float %2, float %3)
483 typedef struct {
484 double d0;
485 } struct_d1;
486 TEST(struct_d1)
487 // CHECK-LABEL: define{{.*}} swiftcc double @return_struct_d1()
488 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d1(double %0)
490 typedef struct {
491 double d0;
492 double d1;
493 } struct_d2;
494 TEST(struct_d2)
496 // CHECK-LABEL: define{{.*}} swiftcc { double, double } @return_struct_d2()
497 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d2(double %0, double %1)
498 typedef struct {
499 double d0;
500 double d1;
501 double d2;
502 } struct_d3;
503 TEST(struct_d3)
504 // CHECK-LABEL: define{{.*}} swiftcc { double, double, double } @return_struct_d3()
505 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d3(double %0, double %1, double %2)
507 typedef struct {
508 double d0;
509 double d1;
510 double d2;
511 double d3;
512 } struct_d4;
513 TEST(struct_d4)
514 // CHECK-LABEL: define{{.*}} swiftcc { double, double, double, double } @return_struct_d4()
515 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d4(double %0, double %1, double %2, double %3)
517 typedef struct {
518 double d0;
519 double d1;
520 double d2;
521 double d3;
522 double d4;
523 } struct_d5;
524 TEST(struct_d5)
525 // CHECK: define{{.*}} swiftcc void @return_struct_d5(ptr noalias sret([[STRUCT5:.+]])
526 // CHECK: define{{.*}} swiftcc void @take_struct_d5(ptr
528 typedef struct {
529 char c0;
530 } struct_c1;
531 TEST(struct_c1)
532 // CHECK-LABEL: define{{.*}} swiftcc i8 @return_struct_c1()
533 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c1(i8 %0)
535 typedef struct {
536 char c0;
537 char c1;
538 } struct_c2;
539 TEST(struct_c2)
540 // CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_c2()
541 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c2(i16 %0)
544 typedef struct {
545 char c0;
546 char c1;
547 char c2;
548 } struct_c3;
549 TEST(struct_c3)
550 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c3()
551 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c3(i32 %0)
553 typedef struct {
554 char c0;
555 char c1;
556 char c2;
557 char c3;
558 } struct_c4;
559 TEST(struct_c4)
560 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c4()
561 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c4(i32 %0)
563 typedef struct {
564 char c0;
565 char c1;
566 char c2;
567 char c3;
568 char c4;
569 } struct_c5;
570 TEST(struct_c5)
571 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_c5()
572 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c5(i64 %0)
574 typedef struct {
575 char c0;
576 char c1;
577 char c2;
578 char c3;
579 char c4;
580 char c5;
581 char c6;
582 char c7;
583 char c8;
584 } struct_c9;
585 TEST(struct_c9)
586 // CHECK-LABEL: define{{.*}} swiftcc { i64, i8 } @return_struct_c9()
587 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c9(i64 %0, i8 %1)
589 typedef struct {
590 short s0;
591 } struct_s1;
592 TEST(struct_s1)
593 // CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_s1()
594 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s1(i16 %0)
596 typedef struct {
597 short s0;
598 short s1;
599 } struct_s2;
600 TEST(struct_s2)
601 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_s2()
602 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s2(i32 %0)
605 typedef struct {
606 short s0;
607 short s1;
608 short s2;
609 } struct_s3;
610 TEST(struct_s3)
611 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_s3()
612 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s3(i64 %0)
614 typedef struct {
615 short s0;
616 short s1;
617 short s2;
618 short s3;
619 } struct_s4;
620 TEST(struct_s4)
621 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_s4()
622 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s4(i64 %0)
624 typedef struct {
625 short s0;
626 short s1;
627 short s2;
628 short s3;
629 short s4;
630 } struct_s5;
631 TEST(struct_s5)
632 // CHECK-LABEL: define{{.*}} swiftcc { i64, i16 } @return_struct_s5()
633 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s5(i64 %0, i16 %1)
636 typedef struct {
637 int i0;
638 } struct_i1;
639 TEST(struct_i1)
640 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_i1()
641 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i1(i32 %0)
643 typedef struct {
644 int i0;
645 int i1;
646 } struct_i2;
647 TEST(struct_i2)
648 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_i2()
649 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i2(i64 %0)
651 typedef struct {
652 int i0;
653 int i1;
654 int i2;
655 } struct_i3;
656 TEST(struct_i3)
657 // CHECK-LABEL: define{{.*}} swiftcc { i64, i32 } @return_struct_i3()
658 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i3(i64 %0, i32 %1)
660 typedef struct {
661 int i0;
662 int i1;
663 int i2;
664 int i3;
665 } struct_i4;
666 TEST(struct_i4)
667 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_i4()
668 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i4(i64 %0, i64 %1)
670 typedef struct {
671 long long l0;
672 } struct_l1;
673 TEST(struct_l1)
674 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_l1()
675 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l1(i64 %0)
677 typedef struct {
678 long long l0;
679 long long l1;
680 } struct_l2;
681 TEST(struct_l2)
682 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_l2()
683 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l2(i64 %0, i64 %1)
685 typedef struct {
686 long long l0;
687 long long l1;
688 long long l2;
689 } struct_l3;
690 TEST(struct_l3)
691 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64, i64 } @return_struct_l3()
692 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l3(i64 %0, i64 %1, i64 %2)
694 typedef struct {
695 long long l0;
696 long long l1;
697 long long l2;
698 long long l3;
699 } struct_l4;
700 TEST(struct_l4)
701 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64, i64, i64 } @return_struct_l4()
702 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l4(i64 %0, i64 %1, i64 %2, i64 %3)
704 typedef struct {
705 long long l0;
706 long long l1;
707 long long l2;
708 long long l3;
709 long long l4;
710 } struct_l5;
711 TEST(struct_l5)
712 // CHECK: define{{.*}} swiftcc void @return_struct_l5(ptr noalias sret([[STRUCT5:.+]])
713 // CHECK: define{{.*}} swiftcc void @take_struct_l5(ptr
715 typedef struct {
716 char16 c0;
717 } struct_vc1;
718 TEST(struct_vc1)
719 // CHECK-LABEL: define{{.*}} swiftcc <16 x i8> @return_struct_vc1()
720 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc1(<16 x i8> %0)
722 typedef struct {
723 char16 c0;
724 char16 c1;
725 } struct_vc2;
726 TEST(struct_vc2)
727 // CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8> } @return_struct_vc2()
728 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc2(<16 x i8> %0, <16 x i8> %1)
730 typedef struct {
731 char16 c0;
732 char16 c1;
733 char16 c2;
734 } struct_vc3;
735 TEST(struct_vc3)
736 // CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc3()
737 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc3(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2)
739 typedef struct {
740 char16 c0;
741 char16 c1;
742 char16 c2;
743 char16 c3;
744 } struct_vc4;
745 TEST(struct_vc4)
746 // CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc4()
747 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc4(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2, <16 x i8> %3)
749 typedef struct {
750 char16 c0;
751 char16 c1;
752 char16 c2;
753 char16 c3;
754 char16 c4;
755 } struct_vc5;
756 TEST(struct_vc5)
757 // CHECK: define{{.*}} swiftcc void @return_struct_vc5(ptr noalias sret([[STRUCT:.+]])
758 // CHECK: define{{.*}} swiftcc void @take_struct_vc5(ptr
760 typedef struct {
761 short8 c0;
762 } struct_vs1;
763 TEST(struct_vs1)
764 // CHECK-LABEL: define{{.*}} swiftcc <8 x i16> @return_struct_vs1()
765 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs1(<8 x i16> %0)
767 typedef struct {
768 short8 c0;
769 short8 c1;
770 } struct_vs2;
771 TEST(struct_vs2)
772 // CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16> } @return_struct_vs2()
773 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs2(<8 x i16> %0, <8 x i16> %1)
775 typedef struct {
776 short8 c0;
777 short8 c1;
778 short8 c2;
779 } struct_vs3;
780 TEST(struct_vs3)
781 // CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs3()
782 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs3(<8 x i16> %0, <8 x i16> %1, <8 x i16> %2)
784 typedef struct {
785 short8 c0;
786 short8 c1;
787 short8 c2;
788 short8 c3;
789 } struct_vs4;
790 TEST(struct_vs4)
791 // CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs4()
792 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs4(<8 x i16> %0, <8 x i16> %1, <8 x i16> %2, <8 x i16> %3)
794 typedef struct {
795 short8 c0;
796 short8 c1;
797 short8 c2;
798 short8 c3;
799 short8 c4;
800 } struct_vs5;
801 TEST(struct_vs5)
802 // CHECK: define{{.*}} swiftcc void @return_struct_vs5(ptr noalias sret([[STRUCT:.+]])
803 // CHECK: define{{.*}} swiftcc void @take_struct_vs5(ptr
805 typedef struct {
806 int4 c0;
807 } struct_vi1;
808 TEST(struct_vi1)
809 // CHECK-LABEL: define{{.*}} swiftcc <4 x i32> @return_struct_vi1()
810 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi1(<4 x i32> %0)
812 typedef struct {
813 int4 c0;
814 int4 c1;
815 } struct_vi2;
816 TEST(struct_vi2)
817 // CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32> } @return_struct_vi2()
818 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi2(<4 x i32> %0, <4 x i32> %1)
820 typedef struct {
821 int4 c0;
822 int4 c1;
823 int4 c2;
824 } struct_vi3;
825 TEST(struct_vi3)
826 // CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32>, <4 x i32> } @return_struct_vi3()
827 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi3(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2)
829 typedef struct {
830 int4 c0;
831 int4 c1;
832 int4 c2;
833 int4 c3;
834 } struct_vi4;
835 TEST(struct_vi4)
836 // CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32> } @return_struct_vi4()
837 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi4(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2, <4 x i32> %3)
839 typedef struct {
840 int4 c0;
841 int4 c1;
842 int4 c2;
843 int4 c3;
844 int4 c4;
845 } struct_vi5;
846 TEST(struct_vi5)
847 // CHECK: define{{.*}} swiftcc void @return_struct_vi5(ptr noalias sret([[STRUCT:.+]])
848 // CHECK: define{{.*}} swiftcc void @take_struct_vi5(ptr
850 typedef struct {
851 long2 c0;
852 } struct_vl1;
853 TEST(struct_vl1)
854 // CHECK-LABEL: define{{.*}} swiftcc <2 x i64> @return_struct_vl1()
855 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vl1(<2 x i64> %0)
857 typedef struct {
858 long2 c0;
859 long2 c1;
860 long2 c2;
861 long2 c3;
862 } struct_vl4;
863 TEST(struct_vl4)
864 // CHECK-LABEL: define{{.*}} swiftcc { <2 x i64>, <2 x i64>, <2 x i64>, <2 x i64> } @return_struct_vl4()
865 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vl4(<2 x i64> %0, <2 x i64> %1, <2 x i64> %2, <2 x i64> %3)
867 typedef struct {
868 long2 c0;
869 long2 c1;
870 long2 c2;
871 long2 c3;
872 long2 c4;
873 } struct_vl5;
874 TEST(struct_vl5)
875 // CHECK: define{{.*}} swiftcc void @return_struct_vl5(ptr noalias sret([[STRUCT:.+]])
876 // CHECK: define{{.*}} swiftcc void @take_struct_vl5(ptr
878 typedef struct {
879 double2 c0;
880 } struct_vd1;
881 TEST(struct_vd1)
882 // CHECK-LABEL: define{{.*}} swiftcc <2 x double> @return_struct_vd1()
883 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd1(<2 x double> %0)
885 typedef struct {
886 double2 c0;
887 double2 c1;
888 double2 c2;
889 double2 c3;
890 } struct_vd4;
891 TEST(struct_vd4)
892 // CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double>, <2 x double>, <2 x double> } @return_struct_vd4()
893 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd4(<2 x double> %0, <2 x double> %1, <2 x double> %2, <2 x double> %3)
895 typedef struct {
896 double2 c0;
897 double2 c1;
898 double2 c2;
899 double2 c3;
900 double2 c4;
901 } struct_vd5;
902 TEST(struct_vd5)
903 // CHECK: define{{.*}} swiftcc void @return_struct_vd5(ptr noalias sret([[STRUCT:.+]])
904 // CHECK: define{{.*}} swiftcc void @take_struct_vd5(ptr
906 typedef struct {
907 double4 c0;
908 } struct_vd41;
909 TEST(struct_vd41)
910 // CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double> } @return_struct_vd41()
911 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd41(<2 x double> %0, <2 x double> %1)
913 typedef struct {
914 double4 c0;
915 double4 c1;
916 } struct_vd42;
917 TEST(struct_vd42)
918 // CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double>, <2 x double>, <2 x double> } @return_struct_vd42()
919 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd42(<2 x double> %0, <2 x double> %1, <2 x double> %2, <2 x double> %3)
921 typedef struct {
922 double4 c0;
923 double4 c1;
924 double4 c2;
925 } struct_vd43;
926 TEST(struct_vd43)
927 // CHECK: define{{.*}} swiftcc void @return_struct_vd43(ptr noalias sret([[STRUCT:.+]])
928 // CHECK: define{{.*}} swiftcc void @take_struct_vd43(ptr
930 typedef struct {
931 float4 c0;
932 } struct_vf1;
933 TEST(struct_vf1)
934 // CHECK-LABEL: define{{.*}} swiftcc <4 x float> @return_struct_vf1()
935 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf1(<4 x float> %0)
937 typedef struct {
938 float4 c0;
939 float4 c1;
940 } struct_vf2;
941 TEST(struct_vf2)
942 // CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float> } @return_struct_vf2()
943 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf2(<4 x float> %0, <4 x float> %1)
945 typedef struct {
946 float4 c0;
947 float4 c1;
948 float4 c2;
949 float4 c3;
950 } struct_vf4;
951 TEST(struct_vf4)
952 // CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float>, <4 x float>, <4 x float> } @return_struct_vf4()
953 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf4(<4 x float> %0, <4 x float> %1, <4 x float> %2, <4 x float> %3)
955 typedef struct {
956 float4 c0;
957 float4 c1;
958 float4 c2;
959 float4 c3;
960 float4 c4;
961 } struct_vf5;
962 TEST(struct_vf5)
963 // CHECK: define{{.*}} swiftcc void @return_struct_vf5(ptr noalias sret([[STRUCT:.+]])
964 // CHECK: define{{.*}} swiftcc void @take_struct_vf5(ptr
966 typedef struct {
967 float8 c0;
968 } struct_vf81;
969 TEST(struct_vf81)
970 // CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float> } @return_struct_vf81()
971 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf81(<4 x float> %0, <4 x float> %1)
973 // Don't crash.
974 typedef union {
975 int4 v[2];
976 struct {
977 int LSW;
978 int d7;
979 int d6;
980 int d5;
981 int d4;
982 int d3;
983 int d2;
984 int MSW;
985 } s;
986 } union_het_vecint;
987 TEST(union_het_vecint)
988 // CHECK: define{{.*}} swiftcc { i64, i64, i64, i64 } @return_union_het_vecint()
989 // CHECK: define{{.*}} swiftcc void @take_union_het_vecint(i64 %0, i64 %1, i64 %2, i64 %3)
991 typedef struct {
992 float3 f3;
993 } struct_v1f3;
994 TEST(struct_v1f3)
995 // ARM64-LABEL: define{{.*}} swiftcc { <2 x float>, float } @return_struct_v1f3()
996 // ARM64-LABEL: define{{.*}} swiftcc void @take_struct_v1f3(<2 x float> %0, float %1)
998 typedef struct {
999 int3 vect;
1000 unsigned long long val;
1001 } __attribute__((packed)) padded_alloc_size_vector;
1002 TEST(padded_alloc_size_vector)
1003 // X86-64-LABEL: take_padded_alloc_size_vector(<3 x i32> %0, i64 %1)
1004 // X86-64-NOT: [4 x i8]
1005 // x86-64: ret void
1007 typedef union {
1008 float f1;
1009 float3 fv2;
1010 } union_hom_fp_partial2;
1011 TEST(union_hom_fp_partial2)
1012 // X86-64-LABEL: take_union_hom_fp_partial2(float %0, float %1, float %2)
1013 // ARM64-LABEL: take_union_hom_fp_partial2(float %0, float %1, float %2)
1015 // At one point, we emitted lifetime.ends without a matching lifetime.start for
1016 // CoerceAndExpanded args. Since we're not performing optimizations, neither
1017 // intrinsic should be emitted.
1018 // CHECK-LABEL: define{{.*}} void @no_lifetime_markers
1019 void no_lifetime_markers() {
1020 // CHECK-NOT: call void @llvm.lifetime.
1021 take_int5(return_int5());
1024 typedef struct {
1025 unsigned long long a;
1026 unsigned long long b;
1027 } double_word;
1029 typedef struct {
1030 _Atomic(double_word) a;
1031 } atomic_double_word;
1033 // CHECK-LABEL: use_atomic(i64 %0, i64 %1)
1034 SWIFTCALL void use_atomic(atomic_double_word a) {}
1036 typedef struct {
1037 unsigned long long a;
1038 unsigned char b;
1039 } __attribute__((packed)) packed;
1041 typedef struct {
1042 _Atomic(packed) a;
1043 } atomic_padded;
1045 // CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1)
1046 SWIFTCALL void use_atomic_padded(atomic_padded a) {}
1049 typedef union {
1050 float4 v;
1051 float3 v2;
1052 struct {
1053 float a;
1054 float b;
1055 float c;
1056 float d;
1058 } vector_union;
1060 TEST(vector_union)
1062 // CHECK-LABEL: define swiftcc { float, float, float, float } @return_vector_union()
1063 // CHECK-LABEL: define swiftcc void @take_vector_union(float %0, float %1, float %2, float %3)