blob: a0e30c6deaf9f55682876acb1de87dbebbbccdab [file] [log] [blame]
Chris Lattner22fd4ba2010-08-25 23:39:14 +00001// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s| FileCheck %s
Eli Friedmanee1ad992011-12-02 00:11:43 +00002// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s -target-feature +avx | FileCheck %s -check-prefix=AVX
Chris Lattnera8b7a7d2010-08-26 06:28:35 +00003#include <stdarg.h>
Daniel Dunbar644f4c32009-02-14 02:09:24 +00004
Stephen Lin93ab6bf2013-08-15 06:47:53 +00005// CHECK-LABEL: define signext i8 @f0()
Daniel Dunbar644f4c32009-02-14 02:09:24 +00006char f0(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +00007 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +00008}
9
Stephen Lin93ab6bf2013-08-15 06:47:53 +000010// CHECK-LABEL: define signext i16 @f1()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000011short f1(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000012 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000013}
14
Stephen Lin93ab6bf2013-08-15 06:47:53 +000015// CHECK-LABEL: define i32 @f2()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000016int f2(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000017 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000018}
19
Stephen Lin93ab6bf2013-08-15 06:47:53 +000020// CHECK-LABEL: define float @f3()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000021float f3(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000022 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000023}
24
Stephen Lin93ab6bf2013-08-15 06:47:53 +000025// CHECK-LABEL: define double @f4()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000026double f4(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000027 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000028}
29
Stephen Lin93ab6bf2013-08-15 06:47:53 +000030// CHECK-LABEL: define x86_fp80 @f5()
Daniel Dunbar644f4c32009-02-14 02:09:24 +000031long double f5(void) {
Mike Stumpc36541e2009-07-21 20:52:43 +000032 return 0;
Daniel Dunbar644f4c32009-02-14 02:09:24 +000033}
34
Stephen Lin93ab6bf2013-08-15 06:47:53 +000035// CHECK-LABEL: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4)
Daniel Dunbar644f4c32009-02-14 02:09:24 +000036void f6(char a0, short a1, int a2, long long a3, void *a4) {
37}
Anders Carlsson730f9092009-02-26 17:38:19 +000038
Stephen Lin93ab6bf2013-08-15 06:47:53 +000039// CHECK-LABEL: define void @f7(i32 %a0)
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000040typedef enum { A, B, C } e7;
41void f7(e7 a0) {
Mike Stump4b871422009-02-26 19:00:14 +000042}
Daniel Dunbar100f4022009-03-06 17:50:25 +000043
44// Test merging/passing of upper eightbyte with X87 class.
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000045//
Stephen Lin93ab6bf2013-08-15 06:47:53 +000046// CHECK-LABEL: define void @f8_1(%union.u8* noalias sret %agg.result)
47// CHECK-LABEL: define void @f8_2(%union.u8* byval align 16 %a0)
Daniel Dunbar100f4022009-03-06 17:50:25 +000048union u8 {
49 long double a;
50 int b;
51};
Mike Stumpc36541e2009-07-21 20:52:43 +000052union u8 f8_1() { while (1) {} }
Daniel Dunbar100f4022009-03-06 17:50:25 +000053void f8_2(union u8 a0) {}
Daniel Dunbar8236bf12009-05-08 22:26:44 +000054
Stephen Lin93ab6bf2013-08-15 06:47:53 +000055// CHECK-LABEL: define i64 @f9()
Mike Stumpc36541e2009-07-21 20:52:43 +000056struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} }
Daniel Dunbar8236bf12009-05-08 22:26:44 +000057
Stephen Lin93ab6bf2013-08-15 06:47:53 +000058// CHECK-LABEL: define void @f10(i64 %a0.coerce)
Daniel Dunbar8236bf12009-05-08 22:26:44 +000059struct s10 { int a; int b; int : 0; };
60void f10(struct s10 a0) {}
61
Stephen Lin93ab6bf2013-08-15 06:47:53 +000062// CHECK-LABEL: define void @f11(%union.anon* noalias sret %agg.result)
Mike Stumpc36541e2009-07-21 20:52:43 +000063union { long double a; float b; } f11() { while (1) {} }
Daniel Dunbar20e95c52009-05-12 15:22:40 +000064
Stephen Lin93ab6bf2013-08-15 06:47:53 +000065// CHECK-LABEL: define i32 @f12_0()
66// CHECK-LABEL: define void @f12_1(i32 %a0.coerce)
Daniel Dunbar7ef455b2009-05-13 18:54:26 +000067struct s12 { int a __attribute__((aligned(16))); };
Mike Stumpc36541e2009-07-21 20:52:43 +000068struct s12 f12_0(void) { while (1) {} }
Daniel Dunbar7ef455b2009-05-13 18:54:26 +000069void f12_1(struct s12 a0) {}
70
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000071// Check that sret parameter is accounted for when checking available integer
72// registers.
Bill Wendlingc1ea4b92013-02-15 05:25:49 +000073// CHECK: define void @f13(%struct.s13_0* noalias sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval align 8 %e, i32 %f)
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000074
75struct s13_0 { long long f0[3]; };
Daniel Dunbar55a759b2009-08-23 19:28:59 +000076struct s13_1 { long long f0[2]; };
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000077struct s13_0 f13(int a, int b, int c, int d,
Daniel Dunbar55a759b2009-08-23 19:28:59 +000078 struct s13_1 e, int f) { while (1) {} }
Daniel Dunbar3a5f5c52009-05-22 17:33:44 +000079
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000080// CHECK: define void @f14({{.*}}, i8 signext %X)
81void f14(int a, int b, int c, int d, int e, int f, char X) {}
82
83// CHECK: define void @f15({{.*}}, i8* %X)
84void f15(int a, int b, int c, int d, int e, int f, void *X) {}
85
86// CHECK: define void @f16({{.*}}, float %X)
Daniel Dunbar86e13ee2009-05-26 16:37:37 +000087void f16(float a, float b, float c, float d, float e, float f, float g, float h,
88 float X) {}
Daniel Dunbar0aa1cba2010-04-21 19:10:54 +000089
90// CHECK: define void @f17({{.*}}, x86_fp80 %X)
Daniel Dunbar86e13ee2009-05-26 16:37:37 +000091void f17(float a, float b, float c, float d, float e, float f, float g, float h,
92 long double X) {}
93
Chris Lattnerfaf23b72010-06-28 19:56:59 +000094// Check for valid coercion. The struct should be passed/returned as i32, not
95// as i64 for better code quality.
96// rdar://8135035
Stephen Lin93ab6bf2013-08-15 06:47:53 +000097// CHECK-LABEL: define void @f18(i32 %a, i32 %f18_arg1.coerce)
Daniel Dunbar55a759b2009-08-23 19:28:59 +000098struct f18_s0 { int f0; };
99void f18(int a, struct f18_s0 f18_arg1) { while (1) {} }
Daniel Dunbarfdf49862009-06-05 07:58:54 +0000100
Daniel Dunbar46c54fb2010-04-21 19:49:55 +0000101// Check byval alignment.
102
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000103// CHECK-LABEL: define void @f19(%struct.s19* byval align 16 %x)
Daniel Dunbar46c54fb2010-04-21 19:49:55 +0000104struct s19 {
105 long double a;
106};
107void f19(struct s19 x) {}
108
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000109// CHECK-LABEL: define void @f20(%struct.s20* byval align 32 %x)
Daniel Dunbar46c54fb2010-04-21 19:49:55 +0000110struct __attribute__((aligned(32))) s20 {
111 int x;
112 int y;
113};
114void f20(struct s20 x) {}
Chris Lattner9c254f02010-06-29 06:01:59 +0000115
116struct StringRef {
117 long x;
118 const char *Ptr;
119};
120
121// rdar://7375902
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000122// CHECK-LABEL: define i8* @f21(i64 %S.coerce0, i8* %S.coerce1)
Chris Lattner9c254f02010-06-29 06:01:59 +0000123const char *f21(struct StringRef S) { return S.x+S.Ptr; }
124
Chris Lattner121b3fa2010-07-05 20:21:00 +0000125// PR7567
126typedef __attribute__ ((aligned(16))) struct f22s { unsigned long long x[2]; } L;
127void f22(L x, L y) { }
128// CHECK: @f22
129// CHECK: %x = alloca{{.*}}, align 16
130// CHECK: %y = alloca{{.*}}, align 16
131
132
Chris Lattner1daf8082010-07-28 22:15:08 +0000133
134// PR7714
135struct f23S {
136 short f0;
137 unsigned f1;
138 int f2;
139};
140
Chris Lattner519f68c2010-07-28 23:06:14 +0000141
Chris Lattner1daf8082010-07-28 22:15:08 +0000142void f23(int A, struct f23S B) {
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000143 // CHECK-LABEL: define void @f23(i32 %A, i64 %B.coerce0, i32 %B.coerce1)
Chris Lattner1daf8082010-07-28 22:15:08 +0000144}
145
Chris Lattner519f68c2010-07-28 23:06:14 +0000146struct f24s { long a; int b; };
Chris Lattner1daf8082010-07-28 22:15:08 +0000147
Chris Lattner519f68c2010-07-28 23:06:14 +0000148struct f23S f24(struct f23S *X, struct f24s *P2) {
149 return *X;
150
Chris Lattner9cbe4f02011-07-09 17:41:47 +0000151 // CHECK: define { i64, i32 } @f24(%struct.f23S* %X, %struct.f24s* %P2)
Chris Lattner519f68c2010-07-28 23:06:14 +0000152}
Chris Lattner1daf8082010-07-28 22:15:08 +0000153
Chris Lattner800588f2010-07-29 06:26:06 +0000154// rdar://8248065
Chris Lattnerab5722e2010-07-28 23:47:21 +0000155typedef float v4f32 __attribute__((__vector_size__(16)));
Chris Lattnerab5722e2010-07-28 23:47:21 +0000156v4f32 f25(v4f32 X) {
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000157 // CHECK-LABEL: define <4 x float> @f25(<4 x float> %X)
Chris Lattner800588f2010-07-29 06:26:06 +0000158 // CHECK-NOT: alloca
Chris Lattnerc10ab192010-07-29 17:14:05 +0000159 // CHECK: alloca <4 x float>
Chris Lattner800588f2010-07-29 06:26:06 +0000160 // CHECK-NOT: alloca
Chris Lattnerc10ab192010-07-29 17:14:05 +0000161 // CHECK: store <4 x float> %X, <4 x float>*
Chris Lattner800588f2010-07-29 06:26:06 +0000162 // CHECK-NOT: store
163 // CHECK: ret <4 x float>
Chris Lattnerab5722e2010-07-28 23:47:21 +0000164 return X+X;
165}
166
Chris Lattner4711cb02010-07-29 04:46:19 +0000167struct foo26 {
168 int *X;
169 float *Y;
170};
Chris Lattnerab5722e2010-07-28 23:47:21 +0000171
Chris Lattner4711cb02010-07-29 04:46:19 +0000172struct foo26 f26(struct foo26 *P) {
Chris Lattner9cbe4f02011-07-09 17:41:47 +0000173 // CHECK: define { i32*, float* } @f26(%struct.foo26* %P)
Chris Lattner4711cb02010-07-29 04:46:19 +0000174 return *P;
175}
Chris Lattner15842bd2010-07-29 05:02:29 +0000176
177
178struct v4f32wrapper {
179 v4f32 v;
180};
181
182struct v4f32wrapper f27(struct v4f32wrapper X) {
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000183 // CHECK-LABEL: define <4 x float> @f27(<4 x float> %X.coerce)
Chris Lattner15842bd2010-07-29 05:02:29 +0000184 return X;
Chris Lattnere2962be2010-07-29 07:30:00 +0000185}
186
Stephen Hines0e2c34f2015-03-23 12:09:02 -0700187// PR22563 - We should unwrap simple structs and arrays to pass
188// and return them in the appropriate vector registers if possible.
189
190typedef float v8f32 __attribute__((__vector_size__(32)));
191struct v8f32wrapper {
192 v8f32 v;
193};
194
195struct v8f32wrapper f27a(struct v8f32wrapper X) {
196 // AVX-LABEL: define <8 x float> @f27a(<8 x float> %X.coerce)
197 return X;
198}
199
200struct v8f32wrapper_wrapper {
201 v8f32 v[1];
202};
203
204struct v8f32wrapper_wrapper f27b(struct v8f32wrapper_wrapper X) {
205 // AVX-LABEL: define <8 x float> @f27b(<8 x float> %X.coerce)
206 return X;
207}
208
Chris Lattnere2962be2010-07-29 07:30:00 +0000209// rdar://5711709
210struct f28c {
211 double x;
212 int y;
213};
214void f28(struct f28c C) {
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000215 // CHECK-LABEL: define void @f28(double %C.coerce0, i32 %C.coerce1)
Chris Lattnere2962be2010-07-29 07:30:00 +0000216}
217
Chris Lattner021c3a32010-07-29 07:43:55 +0000218struct f29a {
219 struct c {
220 double x;
221 int y;
222 } x[1];
223};
224
225void f29a(struct f29a A) {
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000226 // CHECK-LABEL: define void @f29a(double %A.coerce0, i32 %A.coerce1)
Chris Lattner021c3a32010-07-29 07:43:55 +0000227}
Chris Lattner9e45a3d2010-07-29 17:34:39 +0000228
229// rdar://8249586
230struct S0 { char f0[8]; char f2; char f3; char f4; };
231void f30(struct S0 p_4) {
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000232 // CHECK-LABEL: define void @f30(i64 %p_4.coerce0, i24 %p_4.coerce1)
Chris Lattner9e45a3d2010-07-29 17:34:39 +0000233}
Chris Lattnerf47c9442010-07-29 18:13:09 +0000234
235// Pass the third element as a float when followed by tail padding.
236// rdar://8251384
237struct f31foo { float a, b, c; };
238float f31(struct f31foo X) {
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000239 // CHECK-LABEL: define float @f31(<2 x float> %X.coerce0, float %X.coerce1)
Chris Lattnerf47c9442010-07-29 18:13:09 +0000240 return X.c;
241}
242
Chris Lattner22fd4ba2010-08-25 23:39:14 +0000243_Complex float f32(_Complex float A, _Complex float B) {
244 // rdar://6379669
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000245 // CHECK-LABEL: define <2 x float> @f32(<2 x float> %A.coerce, <2 x float> %B.coerce)
Chris Lattner22fd4ba2010-08-25 23:39:14 +0000246 return A+B;
247}
248
Chris Lattnerf47c9442010-07-29 18:13:09 +0000249
Chris Lattnera8b7a7d2010-08-26 06:28:35 +0000250// rdar://8357396
251struct f33s { long x; float c,d; };
252
253void f33(va_list X) {
254 va_arg(X, struct f33s);
255}
256
Chris Lattner473f8e72010-08-26 18:03:20 +0000257typedef unsigned long long v1i64 __attribute__((__vector_size__(8)));
258
259// rdar://8359248
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000260// CHECK-LABEL: define i64 @f34(i64 %arg.coerce)
Chris Lattner473f8e72010-08-26 18:03:20 +0000261v1i64 f34(v1i64 arg) { return arg; }
Chris Lattnera8b7a7d2010-08-26 06:28:35 +0000262
Chris Lattner0fefa412010-08-26 18:13:50 +0000263
264// rdar://8358475
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000265// CHECK-LABEL: define i64 @f35(i64 %arg.coerce)
Chris Lattner0fefa412010-08-26 18:13:50 +0000266typedef unsigned long v1i64_2 __attribute__((__vector_size__(8)));
267v1i64_2 f35(v1i64_2 arg) { return arg+arg; }
268
John McCall67a57732011-04-21 01:20:55 +0000269// rdar://9122143
Bill Wendlingc1ea4b92013-02-15 05:25:49 +0000270// CHECK: declare void @func(%struct._str* byval align 16)
John McCall67a57732011-04-21 01:20:55 +0000271typedef struct _str {
272 union {
273 long double a;
274 long c;
275 };
276} str;
277
278void func(str s);
279str ss;
280void f9122143()
281{
282 func(ss);
283}
284
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000285// CHECK-LABEL: define double @f36(double %arg.coerce)
Eli Friedman14508ff2011-07-02 00:57:27 +0000286typedef unsigned v2i32 __attribute((__vector_size__(8)));
287v2i32 f36(v2i32 arg) { return arg; }
Bruno Cardoso Lopes4943c152011-07-11 22:41:29 +0000288
Eli Friedmanee1ad992011-12-02 00:11:43 +0000289// AVX: declare void @f38(<8 x float>)
290// AVX: declare void @f37(<8 x float>)
Bill Wendlingc1ea4b92013-02-15 05:25:49 +0000291// CHECK: declare void @f38(%struct.s256* byval align 32)
292// CHECK: declare void @f37(<8 x float>* byval align 32)
Bruno Cardoso Lopes4943c152011-07-11 22:41:29 +0000293typedef float __m256 __attribute__ ((__vector_size__ (32)));
294typedef struct {
295 __m256 m;
296} s256;
297
298s256 x38;
299__m256 x37;
300
301void f38(s256 x);
302void f37(__m256 x);
303void f39() { f38(x38); f37(x37); }
304
Bruno Cardoso Lopes089d8922011-07-12 01:27:38 +0000305// The two next tests make sure that the struct below is passed
306// in the same way regardless of avx being used
307
Bill Wendlingc1ea4b92013-02-15 05:25:49 +0000308// CHECK: declare void @func40(%struct.t128* byval align 16)
Bruno Cardoso Lopes4943c152011-07-11 22:41:29 +0000309typedef float __m128 __attribute__ ((__vector_size__ (16)));
Bruno Cardoso Lopesccafadb2011-07-12 00:30:27 +0000310typedef struct t128 {
Bruno Cardoso Lopes4943c152011-07-11 22:41:29 +0000311 __m128 m;
312 __m128 n;
313} two128;
314
315extern void func40(two128 s);
316void func41(two128 s) {
317 func40(s);
318}
319
Bill Wendlingc1ea4b92013-02-15 05:25:49 +0000320// CHECK: declare void @func42(%struct.t128_2* byval align 16)
Bruno Cardoso Lopes089d8922011-07-12 01:27:38 +0000321typedef struct xxx {
322 __m128 array[2];
323} Atwo128;
324typedef struct t128_2 {
325 Atwo128 x;
326} SA;
327
328extern void func42(SA s);
329void func43(SA s) {
330 func42(s);
331}
Eli Friedman8d2fe422011-11-18 02:44:19 +0000332
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000333// CHECK-LABEL: define i32 @f44
Eli Friedman8d2fe422011-11-18 02:44:19 +0000334// CHECK: ptrtoint
335// CHECK-NEXT: and {{.*}}, -32
336// CHECK-NEXT: inttoptr
337typedef int T44 __attribute((vector_size(32)));
338struct s44 { T44 x; int y; };
339int f44(int i, ...) {
340 __builtin_va_list ap;
341 __builtin_va_start(ap, i);
342 struct s44 s = __builtin_va_arg(ap, struct s44);
343 __builtin_va_end(ap);
344 return s.y;
345}
Tanya Lattnerce275672011-11-28 23:18:11 +0000346
347// Text that vec3 returns the correct LLVM IR type.
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000348// AVX-LABEL: define i32 @foo(<3 x i64> %X)
Tanya Lattnerce275672011-11-28 23:18:11 +0000349typedef long long3 __attribute((ext_vector_type(3)));
350int foo(long3 X)
351{
352 return 0;
353}
Eli Friedman3ed79032011-12-01 04:53:19 +0000354
355// Make sure we don't use a varargs convention for a function without a
356// prototype where AVX types are involved.
Eli Friedmanee1ad992011-12-02 00:11:43 +0000357// AVX: @test45
358// AVX: call i32 bitcast (i32 (...)* @f45 to i32 (<8 x float>)*)
Eli Friedman3ed79032011-12-01 04:53:19 +0000359int f45();
360__m256 x45;
361void test45() { f45(x45); }
Eli Friedmanee1ad992011-12-02 00:11:43 +0000362
363// Make sure we use byval to pass 64-bit vectors in memory; the LLVM call
364// lowering can't handle this case correctly because it runs after legalization.
365// CHECK: @test46
Bill Wendlingc1ea4b92013-02-15 05:25:49 +0000366// CHECK: call void @f46({{.*}}<2 x float>* byval align 8 {{.*}}, <2 x float>* byval align 8 {{.*}})
Eli Friedmanee1ad992011-12-02 00:11:43 +0000367typedef float v46 __attribute((vector_size(8)));
368void f46(v46,v46,v46,v46,v46,v46,v46,v46,v46,v46);
369void test46() { v46 x = {1,2}; f46(x,x,x,x,x,x,x,x,x,x); }
Daniel Dunbaredfac032012-03-10 01:03:58 +0000370
371// Check that we pass the struct below without using byval, which helps out
372// codegen.
373//
374// CHECK: @test47
375// CHECK: call void @f47(i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}}, i32 {{.*}})
376struct s47 { unsigned a; };
377void f47(int,int,int,int,int,int,struct s47);
378void test47(int a, struct s47 b) { f47(a, a, a, a, a, a, b); }
Manman Renf51c61c2012-11-28 22:08:52 +0000379
380// rdar://12723368
381// In the following example, there are holes in T4 at the 3rd byte and the 4th
382// byte, however, T2 does not have those holes. T4 is chosen to be the
383// representing type for union T1, but we can't use load or store of T4 since
384// it will skip the 3rd byte and the 4th byte.
385// In general, Since we don't accurately represent the data fields of a union,
386// do not use load or store of the representing llvm type for the union.
387typedef _Complex int T2;
388typedef _Complex char T5;
389typedef _Complex int T7;
390typedef struct T4 { T5 field0; T7 field1; } T4;
391typedef union T1 { T2 field0; T4 field1; } T1;
392extern T1 T1_retval;
393T1 test48(void) {
394// CHECK: @test48
Manman Ren060f34d2012-11-28 22:29:41 +0000395// CHECK: memcpy
396// CHECK: memcpy
Manman Renf51c61c2012-11-28 22:08:52 +0000397 return T1_retval;
398}
John McCalle56bb362012-12-07 07:03:17 +0000399
400void test49_helper(double, ...);
401void test49(double d, double e) {
402 test49_helper(d, e);
403}
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000404// CHECK-LABEL: define void @test49(
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700405// CHECK: [[T0:%.*]] = load double, double*
406// CHECK-NEXT: [[T1:%.*]] = load double, double*
John McCalle56bb362012-12-07 07:03:17 +0000407// CHECK-NEXT: call void (double, ...)* @test49_helper(double [[T0]], double [[T1]])
408
409void test50_helper();
410void test50(double d, double e) {
411 test50_helper(d, e);
412}
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000413// CHECK-LABEL: define void @test50(
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700414// CHECK: [[T0:%.*]] = load double, double*
415// CHECK-NEXT: [[T1:%.*]] = load double, double*
John McCalle56bb362012-12-07 07:03:17 +0000416// CHECK-NEXT: call void (double, double, ...)* bitcast (void (...)* @test50_helper to void (double, double, ...)*)(double [[T0]], double [[T1]])
Eli Friedmaneeb00622013-06-07 23:20:55 +0000417
418struct test51_s { __uint128_t intval; };
419void test51(struct test51_s *s, __builtin_va_list argList) {
420 *s = __builtin_va_arg(argList, struct test51_s);
421}
422
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000423// CHECK-LABEL: define void @test51
Eli Friedman939d83e2013-06-11 01:59:28 +0000424// CHECK: [[TMP_ADDR:%.*]] = alloca [[STRUCT_TEST51:%.*]], align 16
425// CHECK: br i1
426// CHECK: [[REG_SAVE_AREA_PTR:%.*]] = getelementptr inbounds {{.*}}, i32 0, i32 3
Pirama Arumuga Nainar3ea9e332015-04-08 08:57:32 -0700427// CHECK-NEXT: [[REG_SAVE_AREA:%.*]] = load i8*, i8** [[REG_SAVE_AREA_PTR]]
428// CHECK-NEXT: [[VALUE_ADDR:%.*]] = getelementptr i8, i8* [[REG_SAVE_AREA]], i32 {{.*}}
Eli Friedman939d83e2013-06-11 01:59:28 +0000429// CHECK-NEXT: [[CASTED_VALUE_ADDR:%.*]] = bitcast i8* [[VALUE_ADDR]] to [[STRUCT_TEST51]]
430// CHECK-NEXT: [[CASTED_TMP_ADDR:%.*]] = bitcast [[STRUCT_TEST51]]* [[TMP_ADDR]] to i8*
431// CHECK-NEXT: [[RECASTED_VALUE_ADDR:%.*]] = bitcast [[STRUCT_TEST51]]* [[CASTED_VALUE_ADDR]] to i8*
432// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[CASTED_TMP_ADDR]], i8* [[RECASTED_VALUE_ADDR]], i64 16, i32 8, i1 false)
433// CHECK-NEXT: add i32 {{.*}}, 16
434// CHECK-NEXT: store i32 {{.*}}, i32* {{.*}}
435// CHECK-NEXT: br label
Eli Friedman7a1b5862013-06-12 00:13:45 +0000436
437void test52_helper(int, ...);
438__m256 x52;
439void test52() {
440 test52_helper(0, x52, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
441}
442// AVX: @test52_helper(i32 0, <8 x float> {{%[a-zA-Z0-9]+}}, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double {{%[a-zA-Z0-9]+}}, double {{%[a-zA-Z0-9]+}})
443
444void test53(__m256 *m, __builtin_va_list argList) {
445 *m = __builtin_va_arg(argList, __m256);
446}
Stephen Lin93ab6bf2013-08-15 06:47:53 +0000447// AVX-LABEL: define void @test53
Eli Friedman7a1b5862013-06-12 00:13:45 +0000448// AVX-NOT: br i1
449// AVX: ret void
450
451void test54_helper(__m256, ...);
452__m256 x54;
453void test54() {
454 test54_helper(x54, x54, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
455 test54_helper(x54, x54, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0i);
456}
457// AVX: @test54_helper(<8 x float> {{%[a-zA-Z0-9]+}}, <8 x float> {{%[a-zA-Z0-9]+}}, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double {{%[a-zA-Z0-9]+}}, double {{%[a-zA-Z0-9]+}})
458// AVX: @test54_helper(<8 x float> {{%[a-zA-Z0-9]+}}, <8 x float> {{%[a-zA-Z0-9]+}}, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, { double, double }* byval align 8 {{%[a-zA-Z0-9]+}})