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() {
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)));
90 SWIFTCALL TYPE return_##TYPE(void) { \
94 SWIFTCALL void take_##TYPE(TYPE v) { \
96 void test_##TYPE() { \
97 take_##TYPE(return_##TYPE()); \
100 /*****************************************************************************/
101 /*********************************** STRUCTS *********************************/
102 /*****************************************************************************/
107 // CHECK-LABEL: define {{.*}} @return_struct_empty()
109 // CHECK-LABEL: define {{.*}} @take_struct_empty()
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]]
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
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]])
159 __attribute__((aligned(2))) char c1
;
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]]
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
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]])
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.
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]]
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
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]])
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 /*****************************************************************************/
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
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]])
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]])
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]])
327 struct { int x
, y
; } f1
;
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]])
353 /*****************************************************************************/
354 /****************************** VECTOR LEGALIZATION **************************/
355 /*****************************************************************************/
358 // CHECK-LABEL: define {{.*}} <4 x i32> @return_int4()
359 // CHECK-LABEL: define {{.*}} @take_int4(<4 x i32>
362 // CHECK-LABEL: define {{.*}} @return_int8()
363 // CHECK: [[RET:%.*]] = alloca [[REC:<8 x i32>]], align 16
364 // CHECK: [[VAR:%.*]] = alloca [[REC]], align
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
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]])
402 // CHECK-LABEL: define {{.*}} @return_int5()
403 // CHECK: [[RET:%.*]] = alloca [[REC:<5 x i32>]], align 16
404 // CHECK: [[VAR:%.*]] = alloca [[REC]], align
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
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]])
443 int3 v
__attribute__((packed
));
445 TEST(misaligned_int3
)
446 // CHECK-LABEL: define{{.*}} swiftcc void @take_misaligned_int3(i64 %0, i64 %1)
452 // CHECK-LABEL: define{{.*}} swiftcc float @return_struct_f1()
453 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f1(float %0)
460 // CHECK-LABEL: define{{.*}} swiftcc { float, float } @return_struct_f2()
461 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_f2(float %0, float %1)
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)
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)
487 // CHECK-LABEL: define{{.*}} swiftcc double @return_struct_d1()
488 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d1(double %0)
496 // CHECK-LABEL: define{{.*}} swiftcc { double, double } @return_struct_d2()
497 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_d2(double %0, double %1)
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)
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)
525 // CHECK: define{{.*}} swiftcc void @return_struct_d5(ptr noalias sret([[STRUCT5:.+]])
526 // CHECK: define{{.*}} swiftcc void @take_struct_d5(ptr
532 // CHECK-LABEL: define{{.*}} swiftcc i8 @return_struct_c1()
533 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c1(i8 %0)
540 // CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_c2()
541 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c2(i16 %0)
550 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c3()
551 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c3(i32 %0)
560 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_c4()
561 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c4(i32 %0)
571 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_c5()
572 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c5(i64 %0)
586 // CHECK-LABEL: define{{.*}} swiftcc { i64, i8 } @return_struct_c9()
587 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_c9(i64 %0, i8 %1)
593 // CHECK-LABEL: define{{.*}} swiftcc i16 @return_struct_s1()
594 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s1(i16 %0)
601 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_s2()
602 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s2(i32 %0)
611 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_s3()
612 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s3(i64 %0)
621 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_s4()
622 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s4(i64 %0)
632 // CHECK-LABEL: define{{.*}} swiftcc { i64, i16 } @return_struct_s5()
633 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_s5(i64 %0, i16 %1)
640 // CHECK-LABEL: define{{.*}} swiftcc i32 @return_struct_i1()
641 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i1(i32 %0)
648 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_i2()
649 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i2(i64 %0)
657 // CHECK-LABEL: define{{.*}} swiftcc { i64, i32 } @return_struct_i3()
658 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i3(i64 %0, i32 %1)
667 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_i4()
668 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_i4(i64 %0, i64 %1)
674 // CHECK-LABEL: define{{.*}} swiftcc i64 @return_struct_l1()
675 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l1(i64 %0)
682 // CHECK-LABEL: define{{.*}} swiftcc { i64, i64 } @return_struct_l2()
683 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_l2(i64 %0, i64 %1)
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)
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)
712 // CHECK: define{{.*}} swiftcc void @return_struct_l5(ptr noalias sret([[STRUCT5:.+]])
713 // CHECK: define{{.*}} swiftcc void @take_struct_l5(ptr
719 // CHECK-LABEL: define{{.*}} swiftcc <16 x i8> @return_struct_vc1()
720 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vc1(<16 x i8> %0)
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)
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)
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)
757 // CHECK: define{{.*}} swiftcc void @return_struct_vc5(ptr noalias sret([[STRUCT:.+]])
758 // CHECK: define{{.*}} swiftcc void @take_struct_vc5(ptr
764 // CHECK-LABEL: define{{.*}} swiftcc <8 x i16> @return_struct_vs1()
765 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vs1(<8 x i16> %0)
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)
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)
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)
802 // CHECK: define{{.*}} swiftcc void @return_struct_vs5(ptr noalias sret([[STRUCT:.+]])
803 // CHECK: define{{.*}} swiftcc void @take_struct_vs5(ptr
809 // CHECK-LABEL: define{{.*}} swiftcc <4 x i32> @return_struct_vi1()
810 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vi1(<4 x i32> %0)
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)
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)
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)
847 // CHECK: define{{.*}} swiftcc void @return_struct_vi5(ptr noalias sret([[STRUCT:.+]])
848 // CHECK: define{{.*}} swiftcc void @take_struct_vi5(ptr
854 // CHECK-LABEL: define{{.*}} swiftcc <2 x i64> @return_struct_vl1()
855 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vl1(<2 x i64> %0)
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)
875 // CHECK: define{{.*}} swiftcc void @return_struct_vl5(ptr noalias sret([[STRUCT:.+]])
876 // CHECK: define{{.*}} swiftcc void @take_struct_vl5(ptr
882 // CHECK-LABEL: define{{.*}} swiftcc <2 x double> @return_struct_vd1()
883 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vd1(<2 x double> %0)
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)
903 // CHECK: define{{.*}} swiftcc void @return_struct_vd5(ptr noalias sret([[STRUCT:.+]])
904 // CHECK: define{{.*}} swiftcc void @take_struct_vd5(ptr
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)
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)
927 // CHECK: define{{.*}} swiftcc void @return_struct_vd43(ptr noalias sret([[STRUCT:.+]])
928 // CHECK: define{{.*}} swiftcc void @take_struct_vd43(ptr
934 // CHECK-LABEL: define{{.*}} swiftcc <4 x float> @return_struct_vf1()
935 // CHECK-LABEL: define{{.*}} swiftcc void @take_struct_vf1(<4 x float> %0)
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)
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)
963 // CHECK: define{{.*}} swiftcc void @return_struct_vf5(ptr noalias sret([[STRUCT:.+]])
964 // CHECK: define{{.*}} swiftcc void @take_struct_vf5(ptr
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)
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)
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)
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]
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());
1025 unsigned long long a
;
1026 unsigned long long b
;
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
) {}
1037 unsigned long long a
;
1039 } __attribute__((packed
)) packed
;
1045 // CHECK-LABEL: use_atomic_padded(i64 %0, i64 %1)
1046 SWIFTCALL
void use_atomic_padded(atomic_padded a
) {}
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)