Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / arm-swiftcall.c
blob677b878c6765da3ac25d27c27a8b2904a6f165ae
1 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple armv7-apple-darwin9 -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple armv7s-apple-ios9 -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple armv7k-apple-ios9 -emit-llvm -o - %s | FileCheck %s
5 #define SWIFTCALL __attribute__((swiftcall))
6 #define SWIFTASYNCCALL __attribute__((swiftasynccall))
7 #define OUT __attribute__((swift_indirect_result))
8 #define ERROR __attribute__((swift_error_result))
9 #define CONTEXT __attribute__((swift_context))
10 #define ASYNC_CONTEXT __attribute__((swift_async_context))
12 /*****************************************************************************/
13 /****************************** PARAMETER ABIS *******************************/
14 /*****************************************************************************/
16 SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {}
17 // CHECK-LABEL: define{{.*}} void @indirect_result_1(ptr noalias sret(ptr) align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}})
19 // TODO: maybe this shouldn't suppress sret.
20 SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); }
21 // CHECK-LABEL: define{{.*}} i32 @indirect_result_2(ptr noalias align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}})
23 typedef struct { char array[1024]; } struct_reallybig;
24 SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); }
25 // CHECK-LABEL: define{{.*}} void @indirect_result_3(ptr dead_on_unwind noalias writable sret(%struct.struct_reallybig) {{.*}}, ptr noalias align 4 dereferenceable(4){{.*}}, ptr noalias align 4 dereferenceable(4){{.*}})
27 SWIFTCALL void context_1(CONTEXT void *self) {}
28 // CHECK-LABEL: define{{.*}} void @context_1(ptr swiftself
30 SWIFTASYNCCALL void async_context_1(ASYNC_CONTEXT void *self) {}
31 // CHECK-LABEL: define{{.*}} void @async_context_1(ptr swiftasync
33 SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {}
34 // CHECK-LABEL: define{{.*}} void @context_2(ptr{{.*}}, ptr swiftself
36 SWIFTASYNCCALL void async_context_2(void *arg0, ASYNC_CONTEXT void *self) {}
37 // CHECK-LABEL: define{{.*}} void @async_context_2(ptr{{.*}}, ptr swiftasync
39 SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {}
40 // CHECK-LABEL: define{{.*}} void @context_error_1(ptr swiftself{{.*}}, ptr swifterror %0)
41 // CHECK: [[TEMP:%.*]] = alloca ptr, align 4
42 // CHECK: [[T0:%.*]] = load ptr, ptr [[ERRORARG:%.*]], align 4
43 // CHECK: store ptr [[T0]], ptr [[TEMP]], align 4
44 // CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 4
45 // CHECK: store ptr [[T0]], ptr [[ERRORARG]], align 4
46 void test_context_error_1(void) {
47 int x;
48 float *error;
49 context_error_1(&x, &error);
51 // CHECK-LABEL: define{{.*}} void @test_context_error_1()
52 // CHECK: [[X:%.*]] = alloca i32, align 4
53 // CHECK: [[ERROR:%.*]] = alloca ptr, align 4
54 // CHECK: [[TEMP:%.*]] = alloca swifterror ptr, align 4
55 // CHECK: [[T0:%.*]] = load ptr, ptr [[ERROR]], align 4
56 // CHECK: store ptr [[T0]], ptr [[TEMP]], align 4
57 // CHECK: call [[SWIFTCC:swiftcc]] void @context_error_1(ptr swiftself [[X]], ptr swifterror [[TEMP]])
58 // CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 4
59 // CHECK: store ptr [[T0]], ptr [[ERROR]], align 4
61 SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float **error) {}
62 // CHECK-LABEL: define{{.*}} void @context_error_2(i16{{.*}}, ptr swiftself{{.*}}, ptr swifterror %0)
64 /*****************************************************************************/
65 /********************************** LOWERING *********************************/
66 /*****************************************************************************/
68 typedef float float3 __attribute__((ext_vector_type(3)));
69 typedef float float4 __attribute__((ext_vector_type(4)));
70 typedef float float8 __attribute__((ext_vector_type(8)));
71 typedef double double2 __attribute__((ext_vector_type(2)));
72 typedef double double4 __attribute__((ext_vector_type(4)));
73 typedef int int3 __attribute__((ext_vector_type(3)));
74 typedef int int4 __attribute__((ext_vector_type(4)));
75 typedef int int5 __attribute__((ext_vector_type(5)));
76 typedef int int8 __attribute__((ext_vector_type(8)));
77 typedef char char16 __attribute__((ext_vector_type(16)));
78 typedef short short8 __attribute__((ext_vector_type(8)));
79 typedef long long long2 __attribute__((ext_vector_type(2)));
81 #define TEST(TYPE) \
82 SWIFTCALL TYPE return_##TYPE(void) { \
83 TYPE result = {}; \
84 return result; \
85 } \
86 SWIFTCALL void take_##TYPE(TYPE v) { \
87 } \
88 void test_##TYPE(void) { \
89 take_##TYPE(return_##TYPE()); \
92 /*****************************************************************************/
93 /*********************************** STRUCTS *********************************/
94 /*****************************************************************************/
96 typedef struct {
97 } struct_empty;
98 TEST(struct_empty);
99 // CHECK-LABEL: define{{.*}} @return_struct_empty()
100 // CHECK: ret void
101 // CHECK-LABEL: define{{.*}} @take_struct_empty()
102 // CHECK: ret void
104 typedef struct {
105 int x;
106 char c0;
107 char c1;
108 float f0;
109 float f1;
110 } struct_1;
111 TEST(struct_1);
112 // CHECK-LABEL: define{{.*}} @return_struct_1()
113 // CHECK: [[RET:%.*]] = alloca [[REC:%.*]], align 4
114 // CHECK: @llvm.memset
115 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ i32, i16, \[2 x i8\], float, float }]], ptr [[RET]], i32 0, i32 0
116 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align 4
117 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1
118 // CHECK: [[SECOND:%.*]] = load i16, ptr [[T0]], align 4
119 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 3
120 // CHECK: [[THIRD:%.*]] = load float, ptr [[T0]], align
121 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 4
122 // CHECK: [[FOURTH:%.*]] = load float, ptr [[T0]], align
123 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i16, float, float }]] poison, i32 [[FIRST]], 0
124 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i16 [[SECOND]], 1
125 // CHECK: [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2
126 // CHECK: [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3
127 // CHECK: ret [[UAGG]] [[T3]]
128 // CHECK-LABEL: define{{.*}} @take_struct_1(i32 %0, i16 %1, float %2, float %3)
129 // CHECK: [[V:%.*]] = alloca [[REC]], align 4
130 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0
131 // CHECK: store i32 %0, ptr [[T0]], align 4
132 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1
133 // CHECK: store i16 %1, ptr [[T0]], align 4
134 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 3
135 // CHECK: store float %2, ptr [[T0]], align 4
136 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 4
137 // CHECK: store float %3, ptr [[T0]], align 4
138 // CHECK: ret void
139 // CHECK-LABEL: define{{.*}} void @test_struct_1()
140 // CHECK: [[TMP:%.*]] = alloca [[REC]], align 4
141 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_struct_1()
142 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
143 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
144 // CHECK: store i32 [[T1]], ptr [[T0]], align 4
145 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
146 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
147 // CHECK: store i16 [[T1]], ptr [[T0]], align 4
148 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
149 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 2
150 // CHECK: store float [[T1]], ptr [[T0]], align 4
151 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 4
152 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 3
153 // CHECK: store float [[T1]], ptr [[T0]], align 4
154 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
155 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align 4
156 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
157 // CHECK: [[SECOND:%.*]] = load i16, ptr [[T0]], align 4
158 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
159 // CHECK: [[THIRD:%.*]] = load float, ptr [[T0]], align 4
160 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 4
161 // CHECK: [[FOURTH:%.*]] = load float, ptr [[T0]], align 4
162 // CHECK: call [[SWIFTCC]] void @take_struct_1(i32 [[FIRST]], i16 [[SECOND]], float [[THIRD]], float [[FOURTH]])
163 // CHECK: ret void
165 typedef struct {
166 int x;
167 char c0;
168 __attribute__((aligned(2))) char c1;
169 float f0;
170 float f1;
171 } struct_2;
172 TEST(struct_2);
173 // CHECK-LABEL: define{{.*}} @return_struct_2()
174 // CHECK: [[RET:%.*]] = alloca [[REC:%.*]], align 4
175 // CHECK: @llvm.memset
176 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ i32, i32, float, float }]], ptr [[RET]], i32 0, i32 0
177 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align 4
178 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1
179 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align 4
180 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 2
181 // CHECK: [[THIRD:%.*]] = load float, ptr [[T0]], align
182 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 3
183 // CHECK: [[FOURTH:%.*]] = load float, ptr [[T0]], align
184 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32, float, float }]] poison, i32 [[FIRST]], 0
185 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
186 // CHECK: [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2
187 // CHECK: [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3
188 // CHECK: ret [[UAGG]] [[T3]]
189 // CHECK-LABEL: define{{.*}} @take_struct_2(i32 %0, i32 %1, float %2, float %3)
190 // CHECK: [[V:%.*]] = alloca [[REC]], align 4
191 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0
192 // CHECK: store i32 %0, ptr [[T0]], align 4
193 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1
194 // CHECK: store i32 %1, ptr [[T0]], align 4
195 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 2
196 // CHECK: store float %2, ptr [[T0]], align 4
197 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 3
198 // CHECK: store float %3, ptr [[T0]], align 4
199 // CHECK: ret void
200 // CHECK-LABEL: define{{.*}} void @test_struct_2()
201 // CHECK: [[TMP:%.*]] = alloca [[REC]], align 4
202 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_struct_2()
203 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
204 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
205 // CHECK: store i32 [[T1]], ptr [[T0]], align 4
206 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
207 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
208 // CHECK: store i32 [[T1]], ptr [[T0]], align 4
209 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 2
210 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 2
211 // CHECK: store float [[T1]], ptr [[T0]], align 4
212 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
213 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 3
214 // CHECK: store float [[T1]], ptr [[T0]], align 4
215 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
216 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align 4
217 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
218 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align 4
219 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 2
220 // CHECK: [[THIRD:%.*]] = load float, ptr [[T0]], align 4
221 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
222 // CHECK: [[FOURTH:%.*]] = load float, ptr [[T0]], align 4
223 // CHECK: call [[SWIFTCC]] void @take_struct_2(i32 [[FIRST]], i32 [[SECOND]], float [[THIRD]], float [[FOURTH]])
224 // CHECK: ret void
226 // There's no way to put a field randomly in the middle of an otherwise
227 // empty storage unit in C, so that case has to be tested in C++, which
228 // can use empty structs to introduce arbitrary padding. (In C, they end up
229 // with size 0 and so don't affect layout.)
231 // Misaligned data rule.
232 typedef struct {
233 char c0;
234 __attribute__((packed)) float f;
235 } struct_misaligned_1;
236 TEST(struct_misaligned_1)
237 // CHECK-LABEL: define{{.*}} @return_struct_misaligned_1()
238 // CHECK: [[RET:%.*]] = alloca [[REC:%.*]], align
239 // CHECK: @llvm.memset
240 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ i32, i8 }]], ptr [[RET]], i32 0, i32 0
241 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align
242 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1
243 // CHECK: [[SECOND:%.*]] = load i8, ptr [[T0]], align
244 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i8 }]] poison, i32 [[FIRST]], 0
245 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i8 [[SECOND]], 1
246 // CHECK: ret [[UAGG]] [[T1]]
247 // CHECK-LABEL: define{{.*}} @take_struct_misaligned_1(i32 %0, i8 %1)
248 // CHECK: [[V:%.*]] = alloca [[REC]], align
249 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0
250 // CHECK: store i32 %0, ptr [[T0]], align
251 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1
252 // CHECK: store i8 %1, ptr [[T0]], align
253 // CHECK: ret void
255 // Too many scalars.
256 typedef struct {
257 int x[5];
258 } struct_big_1;
259 TEST(struct_big_1)
261 // CHECK-LABEL: define{{.*}} void @return_struct_big_1({{.*}} dead_on_unwind noalias writable sret({{.*}})
263 // Should not be byval.
264 // CHECK-LABEL: define{{.*}} void @take_struct_big_1(ptr{{( %.*)?}})
266 /*****************************************************************************/
267 /********************************* TYPE MERGING ******************************/
268 /*****************************************************************************/
270 typedef union {
271 float f;
272 double d;
273 } union_het_fp;
274 TEST(union_het_fp)
275 // CHECK-LABEL: define{{.*}} @return_union_het_fp()
276 // CHECK: [[RET:%.*]] = alloca [[REC:%.*]], align {{(4|8)}}
277 // CHECK: @llvm.memset
278 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ i32, i32 }]], ptr [[RET]], i32 0, i32 0
279 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align {{(4|8)}}
280 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1
281 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align {{(4|8)}}
282 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32 }]] poison, i32 [[FIRST]], 0
283 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
284 // CHECK: ret [[UAGG]] [[T1]]
285 // CHECK-LABEL: define{{.*}} @take_union_het_fp(i32 %0, i32 %1)
286 // CHECK: [[V:%.*]] = alloca [[REC]], align {{(4|8)}}
287 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0
288 // CHECK: store i32 %0, ptr [[T0]], align {{(4|8)}}
289 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1
290 // CHECK: store i32 %1, ptr [[T0]], align {{(4|8)}}
291 // CHECK: ret void
292 // CHECK-LABEL: define{{.*}} void @test_union_het_fp()
293 // CHECK: [[TMP:%.*]] = alloca [[REC]], align {{(4|8)}}
294 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_union_het_fp()
295 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
296 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
297 // CHECK: store i32 [[T1]], ptr [[T0]], align {{(4|8)}}
298 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
299 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
300 // CHECK: store i32 [[T1]], ptr [[T0]], align {{(4|8)}}
301 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
302 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align {{(4|8)}}
303 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
304 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align {{(4|8)}}
305 // CHECK: call [[SWIFTCC]] void @take_union_het_fp(i32 [[FIRST]], i32 [[SECOND]])
306 // CHECK: ret void
309 typedef union {
310 float f1;
311 float f2;
312 } union_hom_fp;
313 TEST(union_hom_fp)
314 // CHECK-LABEL: define{{.*}} void @test_union_hom_fp()
315 // CHECK: [[TMP:%.*]] = alloca [[REC:%.*]], align 4
316 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] float @return_union_hom_fp()
317 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ float }]], ptr [[TMP]], i32 0, i32 0
318 // CHECK: store float [[CALL]], ptr [[T0]], align 4
319 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
320 // CHECK: [[FIRST:%.*]] = load float, ptr [[T0]], align 4
321 // CHECK: call [[SWIFTCC]] void @take_union_hom_fp(float [[FIRST]])
322 // CHECK: ret void
324 typedef union {
325 float f1;
326 float4 fv2;
327 } union_hom_fp_partial;
328 TEST(union_hom_fp_partial)
329 // CHECK-LABEL: define{{.*}} void @test_union_hom_fp_partial()
330 // CHECK: [[TMP:%.*]] = alloca [[REC:%.*]], align 16
331 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG:{ float, float, float, float }]] @return_union_hom_fp_partial()
332 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ float, float, float, float }]], ptr [[TMP]], i32 0, i32 0
333 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
334 // CHECK: store float [[T1]], ptr [[T0]], align
335 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
336 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
337 // CHECK: store float [[T1]], ptr [[T0]], align
338 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 2
339 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 2
340 // CHECK: store float [[T1]], ptr [[T0]], align
341 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
342 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 3
343 // CHECK: store float [[T1]], ptr [[T0]], align
344 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
345 // CHECK: [[FIRST:%.*]] = load float, ptr [[T0]], align
346 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
347 // CHECK: [[SECOND:%.*]] = load float, ptr [[T0]], align
348 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 2
349 // CHECK: [[THIRD:%.*]] = load float, ptr [[T0]], align
350 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
351 // CHECK: [[FOURTH:%.*]] = load float, ptr [[T0]], align
352 // CHECK: call [[SWIFTCC]] void @take_union_hom_fp_partial(float [[FIRST]], float [[SECOND]], float [[THIRD]], float [[FOURTH]])
353 // CHECK: ret void
355 typedef union {
356 struct { int x, y; } f1;
357 float4 fv2;
358 } union_het_fpv_partial;
359 TEST(union_het_fpv_partial)
360 // CHECK-LABEL: define{{.*}} void @test_union_het_fpv_partial()
361 // CHECK: [[TMP:%.*]] = alloca [[REC:%.*]], align 16
362 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG:{ i32, i32, float, float }]] @return_union_het_fpv_partial()
363 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ i32, i32, float, float }]], ptr [[TMP]], i32 0, i32 0
364 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
365 // CHECK: store i32 [[T1]], ptr [[T0]], align
366 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
367 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
368 // CHECK: store i32 [[T1]], ptr [[T0]], align
369 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 2
370 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 2
371 // CHECK: store float [[T1]], ptr [[T0]], align
372 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
373 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 3
374 // CHECK: store float [[T1]], ptr [[T0]], align
375 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 0
376 // CHECK: [[FIRST:%.*]] = load i32, ptr [[T0]], align
377 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 1
378 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align
379 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 2
380 // CHECK: [[THIRD:%.*]] = load float, ptr [[T0]], align
381 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP]], i32 0, i32 3
382 // CHECK: [[FOURTH:%.*]] = load float, ptr [[T0]], align
383 // CHECK: call [[SWIFTCC]] void @take_union_het_fpv_partial(i32 [[FIRST]], i32 [[SECOND]], float [[THIRD]], float [[FOURTH]])
384 // CHECK: ret void
386 /*****************************************************************************/
387 /****************************** VECTOR LEGALIZATION **************************/
388 /*****************************************************************************/
390 TEST(int4)
391 // CHECK-LABEL: define{{.*}} <4 x i32> @return_int4()
392 // CHECK-LABEL: define{{.*}} @take_int4(<4 x i32>
394 TEST(int8)
395 // CHECK-LABEL: define{{.*}} @return_int8()
396 // CHECK: [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 32
397 // CHECK: store
398 // CHECK: load
399 // CHECK: store
400 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ <4 x i32>, <4 x i32> }]], ptr [[RET]], i32 0, i32 0
401 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
402 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1
403 // CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align
404 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, <4 x i32> [[FIRST]], 0
405 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1
406 // CHECK: ret [[UAGG]] [[T1]]
407 // CHECK-LABEL: define{{.*}} @take_int8(<4 x i32> %0, <4 x i32> %1)
408 // CHECK: [[V:%.*]] = alloca [[REC]], align
409 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0
410 // CHECK: store <4 x i32> %0, ptr [[T0]], align
411 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1
412 // CHECK: store <4 x i32> %1, ptr [[T0]], align
413 // CHECK: ret void
414 // CHECK-LABEL: define{{.*}} void @test_int8()
415 // CHECK: [[TMP1:%.*]] = alloca [[REC]], align
416 // CHECK: [[TMP2:%.*]] = alloca [[REC]], align
417 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int8()
418 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 0
419 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
420 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
421 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 1
422 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
423 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
424 // CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align
425 // CHECK: store [[REC]] [[V]], ptr [[TMP2]], align
426 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 0
427 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
428 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 1
429 // CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align
430 // CHECK: call [[SWIFTCC]] void @take_int8(<4 x i32> [[FIRST]], <4 x i32> [[SECOND]])
431 // CHECK: ret void
433 TEST(int5)
434 // CHECK-LABEL: define{{.*}} @return_int5()
435 // CHECK: [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 32
436 // CHECK: store
437 // CHECK: load
438 // CHECK: store
439 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG:{ <4 x i32>, i32 }]], ptr [[RET]], i32 0, i32 0
440 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
441 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[RET]], i32 0, i32 1
442 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align
443 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x i32> [[FIRST]], 0
444 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
445 // CHECK: ret [[UAGG]] [[T1]]
446 // CHECK-LABEL: define{{.*}} @take_int5(<4 x i32> %0, i32 %1)
447 // CHECK: [[V:%.*]] = alloca [[REC]], align
448 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 0
449 // CHECK: store <4 x i32> %0, ptr [[T0]], align
450 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[V]], i32 0, i32 1
451 // CHECK: store i32 %1, ptr [[T0]], align
452 // CHECK: ret void
453 // CHECK-LABEL: define{{.*}} void @test_int5()
454 // CHECK: [[TMP1:%.*]] = alloca [[REC]], align
455 // CHECK: [[TMP2:%.*]] = alloca [[REC]], align
456 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int5()
457 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 0
458 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
459 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
460 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP1]], i32 0, i32 1
461 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
462 // CHECK: store i32 [[T1]], ptr [[T0]], align
463 // CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align
464 // CHECK: store [[REC]] [[V]], ptr [[TMP2]], align
465 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 0
466 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
467 // CHECK: [[T0:%.*]] = getelementptr inbounds nuw [[AGG]], ptr [[TMP2]], i32 0, i32 1
468 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align
469 // CHECK: call [[SWIFTCC]] void @take_int5(<4 x i32> [[FIRST]], i32 [[SECOND]])
470 // CHECK: ret void
472 typedef struct {
473 int x;
474 int3 v __attribute__((packed));
475 } misaligned_int3;
476 TEST(misaligned_int3)
477 // CHECK-LABEL: define{{.*}} @take_misaligned_int3(i32 %0, i32 %1, i32 %2, i32 %3)
479 typedef struct {
480 float f0;
481 } struct_f1;
482 TEST(struct_f1)
483 // CHECK-LABEL: define{{.*}} swiftcc float @return_struct_f1()
484 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f1(float %0)
486 typedef struct {
487 float f0;
488 float f1;
489 } struct_f2;
490 TEST(struct_f2)
491 // CHECK-LABEL: define{{.*}} swiftcc { float, float } @return_struct_f2()
492 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f2(float %0, float %1)
494 typedef struct {
495 float f0;
496 float f1;
497 float f2;
498 } struct_f3;
499 TEST(struct_f3)
500 // CHECK-LABEL: define{{.*}} swiftcc { float, float, float } @return_struct_f3()
501 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f3(float %0, float %1, float %2)
503 typedef struct {
504 float f0;
505 float f1;
506 float f2;
507 float f3;
508 } struct_f4;
509 TEST(struct_f4)
510 // CHECK-LABEL: define{{.*}} swiftcc { float, float, float, float } @return_struct_f4()
511 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f4(float %0, float %1, float %2, float %3)
514 typedef struct {
515 double d0;
516 } struct_d1;
517 TEST(struct_d1)
518 // CHECK-LABEL: define{{.*}} swiftcc double @return_struct_d1()
519 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d1(double %0)
521 typedef struct {
522 double d0;
523 double d1;
524 } struct_d2;
525 TEST(struct_d2)
526 // CHECK-LABEL: define{{.*}} swiftcc { double, double } @return_struct_d2()
527 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d2(double %0, double %1)
529 typedef struct {
530 double d0;
531 double d1;
532 double d2;
533 } struct_d3;
534 TEST(struct_d3)
535 // CHECK-LABEL: define{{.*}} swiftcc { double, double, double } @return_struct_d3()
536 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d3(double %0, double %1, double %2)
538 typedef struct {
539 double d0;
540 double d1;
541 double d2;
542 double d3;
543 } struct_d4;
544 TEST(struct_d4)
545 // CHECK-LABEL: define{{.*}} swiftcc { double, double, double, double } @return_struct_d4()
546 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d4(double %0, double %1, double %2, double %3)
548 typedef struct {
549 double d0;
550 double d1;
551 double d2;
552 double d3;
553 double d4;
554 } struct_d5;
555 TEST(struct_d5)
556 // CHECK: define{{.*}} swiftcc void @return_struct_d5(ptr dead_on_unwind noalias writable sret([[STRUCT5:%.*]])
557 // CHECK: define{{.*}} swiftcc void @take_struct_d5(ptr
559 typedef struct {
560 char c0;
561 } struct_c1;
562 TEST(struct_c1)
563 // CHECK-LABEL: define{{.*}} swiftcc i8 @return_struct_c1()
564 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c1(i8 %0)
566 typedef struct {
567 char c0;
568 char c1;
569 } struct_c2;
570 TEST(struct_c2)
571 // CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_c2()
572 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c2(i16 %0)
575 typedef struct {
576 char c0;
577 char c1;
578 char c2;
579 } struct_c3;
580 TEST(struct_c3)
581 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c3()
582 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c3(i32 %0)
584 typedef struct {
585 char c0;
586 char c1;
587 char c2;
588 char c3;
589 } struct_c4;
590 TEST(struct_c4)
591 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c4()
592 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c4(i32 %0)
594 typedef struct {
595 char c0;
596 char c1;
597 char c2;
598 char c3;
599 char c4;
600 } struct_c5;
601 TEST(struct_c5)
602 // CHECK-LABEL: define{{.*}} swiftcc { i32, i8 } @return_struct_c5()
603 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c5(i32 %0, i8 %1)
605 typedef struct {
606 short s0;
607 } struct_s1;
608 TEST(struct_s1)
609 // CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_s1()
610 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s1(i16 %0)
612 typedef struct {
613 short s0;
614 short s1;
615 } struct_s2;
616 TEST(struct_s2)
617 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_s2()
618 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s2(i32 %0)
620 typedef struct {
621 short s0;
622 short s1;
623 short s2;
624 } struct_s3;
625 TEST(struct_s3)
626 // CHECK-LABEL: define{{.*}} swiftcc { i32, i16 } @return_struct_s3()
627 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s3(i32 %0, i16 %1)
629 typedef struct {
630 short s0;
631 short s1;
632 short s2;
633 short s3;
634 } struct_s4;
635 TEST(struct_s4)
636 // CHECK-LABEL: define{{.*}} swiftcc { i32, i32 } @return_struct_s4()
637 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s4(i32 %0, i32 %1)
639 typedef struct {
640 short s0;
641 short s1;
642 short s2;
643 short s3;
644 short s4;
645 } struct_s5;
646 TEST(struct_s5)
647 // CHECK-LABEL: define{{.*}} swiftcc { i32, i32, i16 } @return_struct_s5()
648 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s5(i32 %0, i32 %1, i16 %2)
651 typedef struct {
652 int i0;
653 } struct_i1;
654 TEST(struct_i1)
655 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_i1()
656 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i1(i32 %0)
658 typedef struct {
659 int i0;
660 int i1;
661 } struct_i2;
662 TEST(struct_i2)
663 // CHECK-LABEL: define{{.*}} swiftcc { i32, i32 } @return_struct_i2()
664 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i2(i32 %0, i32 %1)
666 typedef struct {
667 int i0;
668 int i1;
669 int i2;
670 } struct_i3;
671 TEST(struct_i3)
672 // CHECK-LABEL: define{{.*}} swiftcc { i32, i32, i32 } @return_struct_i3()
673 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i3(i32 %0, i32 %1, i32 %2)
675 typedef struct {
676 int i0;
677 int i1;
678 int i2;
679 int i3;
680 } struct_i4;
681 TEST(struct_i4)
682 // CHECK-LABEL: define{{.*}} swiftcc { i32, i32, i32, i32 } @return_struct_i4()
683 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i4(i32 %0, i32 %1, i32 %2, i32 %3)
685 typedef struct {
686 long long l0;
687 } struct_l1;
688 TEST(struct_l1)
689 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_l1()
690 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l1(i64 %0)
692 typedef struct {
693 long long l0;
694 long long l1;
695 } struct_l2;
696 TEST(struct_l2)
697 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_l2()
698 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l2(i64 %0, i64 %1)
700 typedef struct {
701 long long l0;
702 long long l1;
703 long long l2;
704 } struct_l3;
705 TEST(struct_l3)
706 // CHECK: define{{.*}} swiftcc void @return_struct_l3(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
707 // CHECK: define{{.*}} swiftcc void @take_struct_l3(ptr
709 typedef struct {
710 long long l0;
711 long long l1;
712 long long l2;
713 long long l3;
714 } struct_l4;
715 TEST(struct_l4)
716 // CHECK: define{{.*}} swiftcc void @return_struct_l4(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
717 // CHECK: define{{.*}} swiftcc void @take_struct_l4(ptr
719 typedef struct {
720 long long l0;
721 long long l1;
722 long long l2;
723 long long l3;
724 long long l4;
725 } struct_l5;
726 TEST(struct_l5)
727 // CHECK: define{{.*}} swiftcc void @return_struct_l5(ptr dead_on_unwind noalias writable sret([[STRUCT5:%.*]])
728 // CHECK: define{{.*}} swiftcc void @take_struct_l5(ptr
730 typedef struct {
731 char16 c0;
732 } struct_vc1;
733 TEST(struct_vc1)
734 // CHECK-LABEL: define{{.*}} swiftcc <16 x i8> @return_struct_vc1()
735 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc1(<16 x i8> %0)
737 typedef struct {
738 char16 c0;
739 char16 c1;
740 } struct_vc2;
741 TEST(struct_vc2)
742 // CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8> } @return_struct_vc2()
743 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc2(<16 x i8> %0, <16 x i8> %1)
745 typedef struct {
746 char16 c0;
747 char16 c1;
748 char16 c2;
749 } struct_vc3;
750 TEST(struct_vc3)
751 // CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc3()
752 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc3(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2)
754 typedef struct {
755 char16 c0;
756 char16 c1;
757 char16 c2;
758 char16 c3;
759 } struct_vc4;
760 TEST(struct_vc4)
761 // CHECK-LABEL: define{{.*}} swiftcc { <16 x i8>, <16 x i8>, <16 x i8>, <16 x i8> } @return_struct_vc4()
762 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc4(<16 x i8> %0, <16 x i8> %1, <16 x i8> %2, <16 x i8> %3)
764 typedef struct {
765 char16 c0;
766 char16 c1;
767 char16 c2;
768 char16 c3;
769 char16 c4;
770 } struct_vc5;
771 TEST(struct_vc5)
772 // CHECK: define{{.*}} swiftcc void @return_struct_vc5(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
773 // CHECK: define{{.*}} swiftcc void @take_struct_vc5(ptr
775 typedef struct {
776 short8 c0;
777 } struct_vs1;
778 TEST(struct_vs1)
779 // CHECK-LABEL: define{{.*}} swiftcc <8 x i16> @return_struct_vs1()
780 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs1(<8 x i16> %0)
782 typedef struct {
783 short8 c0;
784 short8 c1;
785 } struct_vs2;
786 TEST(struct_vs2)
787 // CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16> } @return_struct_vs2()
788 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs2(<8 x i16> %0, <8 x i16> %1)
790 typedef struct {
791 short8 c0;
792 short8 c1;
793 short8 c2;
794 } struct_vs3;
795 TEST(struct_vs3)
796 // CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs3()
797 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs3(<8 x i16> %0, <8 x i16> %1, <8 x i16> %2)
799 typedef struct {
800 short8 c0;
801 short8 c1;
802 short8 c2;
803 short8 c3;
804 } struct_vs4;
805 TEST(struct_vs4)
806 // CHECK-LABEL: define{{.*}} swiftcc { <8 x i16>, <8 x i16>, <8 x i16>, <8 x i16> } @return_struct_vs4()
807 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs4(<8 x i16> %0, <8 x i16> %1, <8 x i16> %2, <8 x i16> %3)
809 typedef struct {
810 short8 c0;
811 short8 c1;
812 short8 c2;
813 short8 c3;
814 short8 c4;
815 } struct_vs5;
816 TEST(struct_vs5)
817 // CHECK: define{{.*}} swiftcc void @return_struct_vs5(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
818 // CHECK: define{{.*}} swiftcc void @take_struct_vs5(ptr
820 typedef struct {
821 int4 c0;
822 } struct_vi1;
823 TEST(struct_vi1)
824 // CHECK-LABEL: define{{.*}} swiftcc <4 x i32> @return_struct_vi1()
825 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi1(<4 x i32> %0)
827 typedef struct {
828 int4 c0;
829 int4 c1;
830 } struct_vi2;
831 TEST(struct_vi2)
832 // CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32> } @return_struct_vi2()
833 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi2(<4 x i32> %0, <4 x i32> %1)
835 typedef struct {
836 int4 c0;
837 int4 c1;
838 int4 c2;
839 } struct_vi3;
840 TEST(struct_vi3)
841 // CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32>, <4 x i32> } @return_struct_vi3()
842 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi3(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2)
844 typedef struct {
845 int4 c0;
846 int4 c1;
847 int4 c2;
848 int4 c3;
849 } struct_vi4;
850 TEST(struct_vi4)
851 // CHECK-LABEL: define{{.*}} swiftcc { <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32> } @return_struct_vi4()
852 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi4(<4 x i32> %0, <4 x i32> %1, <4 x i32> %2, <4 x i32> %3)
854 typedef struct {
855 int4 c0;
856 int4 c1;
857 int4 c2;
858 int4 c3;
859 int4 c4;
860 } struct_vi5;
861 TEST(struct_vi5)
862 // CHECK: define{{.*}} swiftcc void @return_struct_vi5(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
863 // CHECK: define{{.*}} swiftcc void @take_struct_vi5(ptr
865 typedef struct {
866 long2 c0;
867 } struct_vl1;
868 TEST(struct_vl1)
869 // CHECK-LABEL: define{{.*}} swiftcc <2 x i64> @return_struct_vl1()
870 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vl1(<2 x i64> %0)
872 typedef struct {
873 long2 c0;
874 long2 c1;
875 long2 c2;
876 long2 c3;
877 } struct_vl4;
878 TEST(struct_vl4)
879 // CHECK-LABEL: define{{.*}} swiftcc { <2 x i64>, <2 x i64>, <2 x i64>, <2 x i64> } @return_struct_vl4()
880 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vl4(<2 x i64> %0, <2 x i64> %1, <2 x i64> %2, <2 x i64> %3)
882 typedef struct {
883 long2 c0;
884 long2 c1;
885 long2 c2;
886 long2 c3;
887 long2 c4;
888 } struct_vl5;
889 TEST(struct_vl5)
890 // CHECK: define{{.*}} swiftcc void @return_struct_vl5(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
891 // CHECK: define{{.*}} swiftcc void @take_struct_vl5(ptr
893 typedef struct {
894 double2 c0;
895 } struct_vd1;
896 TEST(struct_vd1)
897 // CHECK-LABEL: define{{.*}} swiftcc <2 x double> @return_struct_vd1()
898 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd1(<2 x double> %0)
900 typedef struct {
901 double2 c0;
902 double2 c1;
903 double2 c2;
904 double2 c3;
905 } struct_vd4;
906 TEST(struct_vd4)
907 // CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double>, <2 x double>, <2 x double> } @return_struct_vd4()
908 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd4(<2 x double> %0, <2 x double> %1, <2 x double> %2, <2 x double> %3)
910 typedef struct {
911 double2 c0;
912 double2 c1;
913 double2 c2;
914 double2 c3;
915 double2 c4;
916 } struct_vd5;
917 TEST(struct_vd5)
918 // CHECK: define{{.*}} swiftcc void @return_struct_vd5(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
919 // CHECK: define{{.*}} swiftcc void @take_struct_vd5(ptr
921 typedef struct {
922 double4 c0;
923 } struct_vd41;
924 TEST(struct_vd41)
925 // CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double> } @return_struct_vd41()
926 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd41(<2 x double> %0, <2 x double> %1)
928 typedef struct {
929 double4 c0;
930 double4 c1;
931 } struct_vd42;
932 TEST(struct_vd42)
933 // CHECK-LABEL: define{{.*}} swiftcc { <2 x double>, <2 x double>, <2 x double>, <2 x double> } @return_struct_vd42()
934 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd42(<2 x double> %0, <2 x double> %1, <2 x double> %2, <2 x double> %3)
936 typedef struct {
937 double4 c0;
938 double4 c1;
939 double4 c2;
940 } struct_vd43;
941 TEST(struct_vd43)
942 // CHECK: define{{.*}} swiftcc void @return_struct_vd43(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
943 // CHECK: define{{.*}} swiftcc void @take_struct_vd43(ptr
945 typedef struct {
946 float4 c0;
947 } struct_vf1;
948 TEST(struct_vf1)
949 // CHECK-LABEL: define{{.*}} swiftcc <4 x float> @return_struct_vf1()
950 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf1(<4 x float> %0)
952 typedef struct {
953 float4 c0;
954 float4 c1;
955 } struct_vf2;
956 TEST(struct_vf2)
957 // CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float> } @return_struct_vf2()
958 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf2(<4 x float> %0, <4 x float> %1)
960 typedef struct {
961 float4 c0;
962 float4 c1;
963 float4 c2;
964 float4 c3;
965 } struct_vf4;
966 TEST(struct_vf4)
967 // CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float>, <4 x float>, <4 x float> } @return_struct_vf4()
968 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf4(<4 x float> %0, <4 x float> %1, <4 x float> %2, <4 x float> %3)
970 typedef struct {
971 float4 c0;
972 float4 c1;
973 float4 c2;
974 float4 c3;
975 float4 c4;
976 } struct_vf5;
977 TEST(struct_vf5)
978 // CHECK: define{{.*}} swiftcc void @return_struct_vf5(ptr dead_on_unwind noalias writable sret([[STRUCT:%.*]])
979 // CHECK: define{{.*}} swiftcc void @take_struct_vf5(ptr
981 typedef struct {
982 float8 c0;
983 } struct_vf81;
984 TEST(struct_vf81)
985 // CHECK-LABEL: define{{.*}} swiftcc { <4 x float>, <4 x float> } @return_struct_vf81()
986 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf81(<4 x float> %0, <4 x float> %1)
988 typedef struct {
989 float3 f3;
990 } struct_v1f3;
991 TEST(struct_v1f3)
992 // CHECK-LABEL: define{{.*}} swiftcc { <2 x float>, float } @return_struct_v1f3()
993 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_v1f3(<2 x float> %0, float %1)