Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / windows-swiftcall.c
blob3e5c8a4d4b9d74efbd915c7dbc8aca018af0135f
1 // RUN: %clang_cc1 -triple x86_64-unknown-windows -emit-llvm -target-cpu core2 -o - %s | FileCheck %s
3 #define SWIFTCALL __attribute__((swiftcall))
4 #define OUT __attribute__((swift_indirect_result))
5 #define ERROR __attribute__((swift_error_result))
6 #define CONTEXT __attribute__((swift_context))
8 // CHECK: [[STRUCT2_RESULT:@.*]] = private {{.*}} constant [[STRUCT2_TYPE:%.*]] { i32 0, i8 0, i8 undef, i8 0, i32 0, i32 0 }
10 /*****************************************************************************/
11 /****************************** PARAMETER ABIS *******************************/
12 /*****************************************************************************/
14 SWIFTCALL void indirect_result_1(OUT int *arg0, OUT float *arg1) {}
15 // CHECK-LABEL: define {{.*}} void @indirect_result_1(ptr noalias noundef sret(ptr) align 4 dereferenceable(4){{.*}}, ptr noalias noundef align 4 dereferenceable(4){{.*}})
17 // TODO: maybe this shouldn't suppress sret.
18 SWIFTCALL int indirect_result_2(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); }
19 // CHECK-LABEL: define {{.*}} i32 @indirect_result_2(ptr noalias noundef align 4 dereferenceable(4){{.*}}, ptr noalias noundef align 4 dereferenceable(4){{.*}})
21 typedef struct { char array[1024]; } struct_reallybig;
22 SWIFTCALL struct_reallybig indirect_result_3(OUT int *arg0, OUT float *arg1) { __builtin_unreachable(); }
23 // CHECK-LABEL: define {{.*}} void @indirect_result_3(ptr noalias sret({{.*}}) {{.*}}, ptr noalias noundef align 4 dereferenceable(4){{.*}}, ptr noalias noundef align 4 dereferenceable(4){{.*}})
25 SWIFTCALL void context_1(CONTEXT void *self) {}
26 // CHECK-LABEL: define {{.*}} void @context_1(ptr noundef swiftself
28 SWIFTCALL void context_2(void *arg0, CONTEXT void *self) {}
29 // CHECK-LABEL: define {{.*}} void @context_2(ptr{{.*}}, ptr noundef swiftself
31 SWIFTCALL void context_error_1(CONTEXT int *self, ERROR float **error) {}
32 // CHECK-LABEL: define {{.*}} void @context_error_1(ptr noundef swiftself{{.*}}, ptr noundef swifterror %0)
33 // CHECK: [[TEMP:%.*]] = alloca ptr, align 8
34 // CHECK: [[T0:%.*]] = load ptr, ptr [[ERRORARG:%.*]], align 8
35 // CHECK: store ptr [[T0]], ptr [[TEMP]], align 8
36 // CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 8
37 // CHECK: store ptr [[T0]], ptr [[ERRORARG]], align 8
38 void test_context_error_1(void) {
39 int x;
40 float *error;
41 context_error_1(&x, &error);
43 // CHECK-LABEL: define dso_local void @test_context_error_1()
44 // CHECK: [[X:%.*]] = alloca i32, align 4
45 // CHECK: [[ERROR:%.*]] = alloca ptr, align 8
46 // CHECK: [[TEMP:%.*]] = alloca swifterror ptr, align 8
47 // CHECK: [[T0:%.*]] = load ptr, ptr [[ERROR]], align 8
48 // CHECK: store ptr [[T0]], ptr [[TEMP]], align 8
49 // CHECK: call [[SWIFTCC:swiftcc]] void @context_error_1(ptr noundef swiftself [[X]], ptr noundef swifterror [[TEMP]])
50 // CHECK: [[T0:%.*]] = load ptr, ptr [[TEMP]], align 8
51 // CHECK: store ptr [[T0]], ptr [[ERROR]], align 8
53 SWIFTCALL void context_error_2(short s, CONTEXT int *self, ERROR float **error) {}
54 // CHECK-LABEL: define {{.*}} void @context_error_2(i16{{.*}}, ptr noundef swiftself{{.*}}, ptr noundef swifterror %0)
56 /*****************************************************************************/
57 /********************************** LOWERING *********************************/
58 /*****************************************************************************/
60 typedef float float4 __attribute__((ext_vector_type(4)));
61 typedef float float8 __attribute__((ext_vector_type(8)));
62 typedef double double2 __attribute__((ext_vector_type(2)));
63 typedef double double4 __attribute__((ext_vector_type(4)));
64 typedef int int3 __attribute__((ext_vector_type(3)));
65 typedef int int4 __attribute__((ext_vector_type(4)));
66 typedef int int5 __attribute__((ext_vector_type(5)));
67 typedef int int8 __attribute__((ext_vector_type(8)));
69 #define TEST(TYPE) \
70 SWIFTCALL TYPE return_##TYPE(void) { \
71 TYPE result = {}; \
72 return result; \
73 } \
74 SWIFTCALL void take_##TYPE(TYPE v) { \
75 } \
76 void test_##TYPE(void) { \
77 take_##TYPE(return_##TYPE()); \
80 /*****************************************************************************/
81 /*********************************** STRUCTS *********************************/
82 /*****************************************************************************/
84 typedef struct {
85 } struct_empty;
86 TEST(struct_empty);
87 // CHECK-LABEL: define {{.*}} @return_struct_empty()
88 // CHECK: ret void
89 // CHECK-LABEL: define {{.*}} @take_struct_empty()
90 // CHECK: ret void
92 typedef struct {
93 int x;
94 char c0;
95 char c1;
96 int f0;
97 int f1;
98 } struct_1;
99 TEST(struct_1);
100 // CHECK-LABEL: define dso_local swiftcc { i64, i64 } @return_struct_1() {{.*}}{
101 // CHECK: [[RET:%.*]] = alloca [[STRUCT1:%.*]], align 4
102 // CHECK: call void @llvm.memset
103 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr %retval, i32 0, i32 0
104 // CHECK: [[T0:%.*]] = load i64, ptr [[GEP0]], align 4
105 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr %retval, i32 0, i32 1
106 // CHECK: [[T1:%.*]] = load i64, ptr [[GEP1]], align 4
107 // CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
108 // CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
109 // CHECK: ret { i64, i64 } [[R1]]
110 // CHECK: }
111 // CHECK-LABEL: define dso_local swiftcc void @take_struct_1(i64 %0, i64 %1) {{.*}}{
112 // CHECK: [[V:%.*]] = alloca [[STRUCT1:%.*]], align 4
113 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 0
114 // CHECK: store i64 %0, ptr [[GEP0]], align 4
115 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 1
116 // CHECK: store i64 %1, ptr [[GEP1]], align 4
117 // CHECK: ret void
118 // CHECK: }
119 // CHECK-LABEL: define dso_local void @test_struct_1() {{.*}}{
120 // CHECK: [[AGG:%.*]] = alloca [[STRUCT1:%.*]], align 4
121 // CHECK: [[RET:%.*]] = call swiftcc { i64, i64 } @return_struct_1()
122 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 0
123 // CHECK: [[E0:%.*]] = extractvalue { i64, i64 } [[RET]], 0
124 // CHECK: store i64 [[E0]], ptr [[GEP0]], align 4
125 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 1
126 // CHECK: [[E1:%.*]] = extractvalue { i64, i64 } [[RET]], 1
127 // CHECK: store i64 [[E1]], ptr [[GEP1]], align 4
128 // CHECK: [[GEP2:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 0
129 // CHECK: [[V0:%.*]] = load i64, ptr [[GEP2]], align 4
130 // CHECK: [[GEP3:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[AGG]], i32 0, i32 1
131 // CHECK: [[V1:%.*]] = load i64, ptr [[GEP3]], align 4
132 // CHECK: call swiftcc void @take_struct_1(i64 [[V0]], i64 [[V1]])
133 // CHECK: ret void
134 // CHECK: }
136 typedef struct {
137 int x;
138 char c0;
139 __attribute__((aligned(2))) char c1;
140 int f0;
141 int f1;
142 } struct_2;
143 TEST(struct_2);
144 // CHECK-LABEL: define dso_local swiftcc { i64, i64 } @return_struct_2() {{.*}}{
145 // CHECK: [[RET:%.*]] = alloca [[STRUCT2_TYPE]], align 4
146 // CHECK: call void @llvm.memcpy{{.*}}({{.*}}[[RET]], {{.*}}[[STRUCT2_RESULT]]
147 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[RET]], i32 0, i32 0
148 // CHECK: [[T0:%.*]] = load i64, ptr [[GEP0]], align 4
149 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[RET]], i32 0, i32 1
150 // CHECK: [[T1:%.*]] = load i64, ptr [[GEP1]], align 4
151 // CHECK: [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
152 // CHECK: [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
153 // CHECK: ret { i64, i64 } [[R1]]
154 // CHECK: }
155 // CHECK-LABEL: define dso_local swiftcc void @take_struct_2(i64 %0, i64 %1) {{.*}}{
156 // CHECK: [[V:%.*]] = alloca [[STRUCT:%.*]], align 4
157 // CHECK: [[GEP0:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 0
158 // CHECK: store i64 %0, ptr [[GEP0]], align 4
159 // CHECK: [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[V]], i32 0, i32 1
160 // CHECK: store i64 %1, ptr [[GEP1]], align 4
161 // CHECK: ret void
162 // CHECK: }
163 // CHECK-LABEL: define dso_local void @test_struct_2() {{.*}} {
164 // CHECK: [[TMP:%.*]] = alloca [[STRUCT2_TYPE]], align 4
165 // CHECK: [[CALL:%.*]] = call swiftcc { i64, i64 } @return_struct_2()
166 // CHECK: [[GEP:%.*]] = getelementptr inbounds {{.*}} [[TMP]], i32 0, i32 0
167 // CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 0
168 // CHECK: store i64 [[T0]], ptr [[GEP]], align 4
169 // CHECK: [[GEP:%.*]] = getelementptr inbounds {{.*}} [[TMP]], i32 0, i32 1
170 // CHECK: [[T0:%.*]] = extractvalue { i64, i64 } [[CALL]], 1
171 // CHECK: store i64 [[T0]], ptr [[GEP]], align 4
172 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[TMP]], i32 0, i32 0
173 // CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 4
174 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64, i64 }, ptr [[TMP]], i32 0, i32 1
175 // CHECK: [[R1:%.*]] = load i64, ptr [[GEP]], align 4
176 // CHECK: call swiftcc void @take_struct_2(i64 [[R0]], i64 [[R1]])
177 // CHECK: ret void
178 // CHECK: }
180 // There's no way to put a field randomly in the middle of an otherwise
181 // empty storage unit in C, so that case has to be tested in C++, which
182 // can use empty structs to introduce arbitrary padding. (In C, they end up
183 // with size 0 and so don't affect layout.)
185 // Misaligned data rule.
186 typedef struct {
187 char c0;
188 __attribute__((packed)) float f;
189 } struct_misaligned_1;
190 TEST(struct_misaligned_1)
191 // CHECK-LABEL: define dso_local swiftcc i64 @return_struct_misaligned_1()
192 // CHECK: [[RET:%.*]] = alloca [[STRUCT:%.*]], align 1
193 // CHECK: call void @llvm.memset{{.*}}(ptr align 1 [[RET]], i8 0, i64 5
194 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[RET]], i32 0, i32 0
195 // CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 1
196 // CHECK: ret i64 [[R0]]
197 // CHECK:}
198 // CHECK-LABEL: define dso_local swiftcc void @take_struct_misaligned_1(i64 %0) {{.*}}{
199 // CHECK: [[V:%.*]] = alloca [[STRUCT:%.*]], align 1
200 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[V]], i32 0, i32 0
201 // CHECK: store i64 %0, ptr [[GEP]], align 1
202 // CHECK: ret void
203 // CHECK: }
204 // CHECK: define dso_local void @test_struct_misaligned_1() {{.*}}{
205 // CHECK: [[AGG:%.*]] = alloca [[STRUCT:%.*]], align 1
206 // CHECK: [[CALL:%.*]] = call swiftcc i64 @return_struct_misaligned_1()
207 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
208 // CHECK: store i64 [[CALL]], ptr [[T1]], align 1
209 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
210 // CHECK: [[P:%.*]] = load i64, ptr [[T1]], align 1
211 // CHECK: call swiftcc void @take_struct_misaligned_1(i64 [[P]])
212 // CHECK: ret void
213 // CHECK: }
215 // Too many scalars.
216 typedef struct {
217 long long x[5];
218 } struct_big_1;
219 TEST(struct_big_1)
221 // CHECK-LABEL: define {{.*}} void @return_struct_big_1({{.*}} noalias sret
223 // Should not be byval.
224 // CHECK-LABEL: define {{.*}} void @take_struct_big_1(ptr noundef{{( %.*)?}})
226 /*****************************************************************************/
227 /********************************* TYPE MERGING ******************************/
228 /*****************************************************************************/
230 typedef union {
231 float f;
232 double d;
233 } union_het_fp;
234 TEST(union_het_fp)
235 // CHECK-LABEL: define dso_local swiftcc i64 @return_union_het_fp()
236 // CHECK: [[RET:%.*]] = alloca [[UNION:%.*]], align 8
237 // CHECK: call void @llvm.memcpy{{.*}}(ptr align {{[0-9]+}} [[RET]]
238 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[RET]], i32 0, i32 0
239 // CHECK: [[R0:%.*]] = load i64, ptr [[GEP]], align 8
240 // CHECK: ret i64 [[R0]]
241 // CHECK-LABEL: define dso_local swiftcc void @take_union_het_fp(i64 %0) {{.*}}{
242 // CHECK: [[V:%.*]] = alloca [[UNION:%.*]], align 8
243 // CHECK: [[GEP:%.*]] = getelementptr inbounds { i64 }, ptr [[V]], i32 0, i32 0
244 // CHECK: store i64 %0, ptr [[GEP]], align 8
245 // CHECK: ret void
246 // CHECK: }
247 // CHECK-LABEL: define dso_local void @test_union_het_fp() {{.*}}{
248 // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 8
249 // CHECK: [[CALL:%.*]] = call swiftcc i64 @return_union_het_fp()
250 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
251 // CHECK: store i64 [[CALL]], ptr [[T1]], align 8
252 // CHECK: [[T1:%.*]] = getelementptr inbounds { i64 }, ptr [[AGG]], i32 0, i32 0
253 // CHECK: [[V0:%.*]] = load i64, ptr [[T1]], align 8
254 // CHECK: call swiftcc void @take_union_het_fp(i64 [[V0]])
255 // CHECK: ret void
256 // CHECK: }
259 typedef union {
260 float f1;
261 float f2;
262 } union_hom_fp;
263 TEST(union_hom_fp)
264 // CHECK-LABEL: define dso_local void @test_union_hom_fp()
265 // CHECK: [[TMP:%.*]] = alloca [[REC:%.*]], align 4
266 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] float @return_union_hom_fp()
267 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG:{ float }]], ptr [[TMP]], i32 0, i32 0
268 // CHECK: store float [[CALL]], ptr [[T0]], align 4
269 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP]], i32 0, i32 0
270 // CHECK: [[FIRST:%.*]] = load float, ptr [[T0]], align 4
271 // CHECK: call [[SWIFTCC]] void @take_union_hom_fp(float [[FIRST]])
272 // CHECK: ret void
274 typedef union {
275 float f1;
276 float4 fv2;
277 } union_hom_fp_partial;
278 TEST(union_hom_fp_partial)
279 // CHECK: define dso_local void @test_union_hom_fp_partial()
280 // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16
281 // CHECK: [[CALL:%.*]] = call swiftcc { float, float, float, float } @return_union_hom_fp_partial()
282 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 0
283 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 0
284 // CHECK: store float [[T1]], ptr [[T0]], align 16
285 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 1
286 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 1
287 // CHECK: store float [[T1]], ptr [[T0]], align 4
288 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 2
289 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 2
290 // CHECK: store float [[T1]], ptr [[T0]], align 8
291 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 3
292 // CHECK: [[T1:%.*]] = extractvalue { float, float, float, float } [[CALL]], 3
293 // CHECK: store float [[T1]], ptr [[T0]], align 4
294 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 0
295 // CHECK: [[V0:%.*]] = load float, ptr [[T0]], align 16
296 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 1
297 // CHECK: [[V1:%.*]] = load float, ptr [[T0]], align 4
298 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 2
299 // CHECK: [[V2:%.*]] = load float, ptr [[T0]], align 8
300 // CHECK: [[T0:%.*]] = getelementptr inbounds { float, float, float, float }, ptr [[AGG]], i32 0, i32 3
301 // CHECK: [[V3:%.*]] = load float, ptr [[T0]], align 4
302 // CHECK: call swiftcc void @take_union_hom_fp_partial(float [[V0]], float [[V1]], float [[V2]], float [[V3]])
303 // CHECK: ret void
304 // CHECK: }
306 typedef union {
307 struct { int x, y; } f1;
308 float4 fv2;
309 } union_het_fpv_partial;
310 TEST(union_het_fpv_partial)
311 // CHECK-LABEL: define dso_local void @test_union_het_fpv_partial()
312 // CHECK: [[AGG:%.*]] = alloca [[UNION:%.*]], align 16
313 // CHECK: [[CALL:%.*]] = call swiftcc { i64, float, float } @return_union_het_fpv_partial()
314 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 0
315 // CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 0
316 // CHECK: store i64 [[T1]], ptr [[T0]], align 16
317 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 1
318 // CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 1
319 // CHECK: store float [[T1]], ptr [[T0]], align 8
320 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 2
321 // CHECK: [[T1:%.*]] = extractvalue { i64, float, float } [[CALL]], 2
322 // CHECK: store float [[T1]], ptr [[T0]], align 4
323 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 0
324 // CHECK: [[V0:%.*]] = load i64, ptr [[T0]], align 16
325 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 1
326 // CHECK: [[V1:%.*]] = load float, ptr [[T0]], align 8
327 // CHECK: [[T0:%.*]] = getelementptr inbounds { i64, float, float }, ptr [[AGG]], i32 0, i32 2
328 // CHECK: [[V2:%.*]] = load float, ptr [[T0]], align 4
329 // CHECK: call swiftcc void @take_union_het_fpv_partial(i64 [[V0]], float [[V1]], float [[V2]])
330 // CHECK: ret void
331 // CHECK: }
333 /*****************************************************************************/
334 /****************************** VECTOR LEGALIZATION **************************/
335 /*****************************************************************************/
337 TEST(int4)
338 // CHECK-LABEL: define {{.*}} <4 x i32> @return_int4()
339 // CHECK-LABEL: define {{.*}} @take_int4(<4 x i32>
341 TEST(int8)
342 // CHECK-LABEL: define {{.*}} @return_int8()
343 // CHECK: [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 32
344 // CHECK: [[VAR:%.*]] = alloca [[REC]], align
345 // CHECK: store
346 // CHECK: load
347 // CHECK: store
348 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG:{ <4 x i32>, <4 x i32> }]], ptr [[RET]], i32 0, i32 0
349 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
350 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[RET]], i32 0, i32 1
351 // CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align
352 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, <4 x i32> [[FIRST]], 0
353 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1
354 // CHECK: ret [[UAGG]] [[T1]]
355 // CHECK-LABEL: define {{.*}} @take_int8(<4 x i32> noundef %0, <4 x i32> noundef %1)
356 // CHECK: [[V:%.*]] = alloca [[REC]], align
357 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 0
358 // CHECK: store <4 x i32> %0, ptr [[T0]], align
359 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 1
360 // CHECK: store <4 x i32> %1, ptr [[T0]], align
361 // CHECK: ret void
362 // CHECK-LABEL: define dso_local void @test_int8()
363 // CHECK: [[TMP1:%.*]] = alloca [[REC]], align
364 // CHECK: [[TMP2:%.*]] = alloca [[REC]], align
365 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int8()
366 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 0
367 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
368 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
369 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 1
370 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
371 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
372 // CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align
373 // CHECK: store [[REC]] [[V]], ptr [[TMP2]], align
374 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 0
375 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
376 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 1
377 // CHECK: [[SECOND:%.*]] = load <4 x i32>, ptr [[T0]], align
378 // CHECK: call [[SWIFTCC]] void @take_int8(<4 x i32> noundef [[FIRST]], <4 x i32> noundef [[SECOND]])
379 // CHECK: ret void
381 TEST(int5)
382 // CHECK-LABEL: define {{.*}} @return_int5()
383 // CHECK: [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 32
384 // CHECK: [[VAR:%.*]] = alloca [[REC]], align
385 // CHECK: store
386 // CHECK: load
387 // CHECK: store
388 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG:{ <4 x i32>, i32 }]], ptr [[RET]], i32 0, i32 0
389 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
390 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[RET]], i32 0, i32 1
391 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align
392 // CHECK: [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x i32> [[FIRST]], 0
393 // CHECK: [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
394 // CHECK: ret [[UAGG]] [[T1]]
395 // CHECK-LABEL: define {{.*}} @take_int5(<4 x i32> %0, i32 %1)
396 // CHECK: [[V:%.*]] = alloca [[REC]], align
397 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 0
398 // CHECK: store <4 x i32> %0, ptr [[T0]], align
399 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[V]], i32 0, i32 1
400 // CHECK: store i32 %1, ptr [[T0]], align
401 // CHECK: ret void
402 // CHECK-LABEL: define dso_local void @test_int5()
403 // CHECK: [[TMP1:%.*]] = alloca [[REC]], align
404 // CHECK: [[TMP2:%.*]] = alloca [[REC]], align
405 // CHECK: [[CALL:%.*]] = call [[SWIFTCC]] [[UAGG]] @return_int5()
406 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 0
407 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 0
408 // CHECK: store <4 x i32> [[T1]], ptr [[T0]], align
409 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP1]], i32 0, i32 1
410 // CHECK: [[T1:%.*]] = extractvalue [[UAGG]] [[CALL]], 1
411 // CHECK: store i32 [[T1]], ptr [[T0]], align
412 // CHECK: [[V:%.*]] = load [[REC]], ptr [[TMP1]], align
413 // CHECK: store [[REC]] [[V]], ptr [[TMP2]], align
414 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 0
415 // CHECK: [[FIRST:%.*]] = load <4 x i32>, ptr [[T0]], align
416 // CHECK: [[T0:%.*]] = getelementptr inbounds [[AGG]], ptr [[TMP2]], i32 0, i32 1
417 // CHECK: [[SECOND:%.*]] = load i32, ptr [[T0]], align
418 // CHECK: call [[SWIFTCC]] void @take_int5(<4 x i32> [[FIRST]], i32 [[SECOND]])
419 // CHECK: ret void
421 typedef struct {
422 int x;
423 int3 v __attribute__((packed));
424 } misaligned_int3;
425 TEST(misaligned_int3)
426 // CHECK-LABEL: define dso_local swiftcc void @take_misaligned_int3(i64 %0, i64 %1)