1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s| FileCheck %s
4 // CHECK: %0 = type { i64, double }
6 // CHECK: define signext i8 @f0()
11 // CHECK: define signext i16 @f1()
16 // CHECK: define i32 @f2()
21 // CHECK: define float @f3()
26 // CHECK: define double @f4()
31 // CHECK: define x86_fp80 @f5()
32 long double f5(void) {
36 // CHECK: define void @f6(i8 signext %a0, i16 signext %a1, i32 %a2, i64 %a3, i8* %a4)
37 void f6(char a0
, short a1
, int a2
, long long a3
, void *a4
) {
40 // CHECK: define void @f7(i32 %a0)
41 typedef enum { A
, B
, C
} e7
;
45 // Test merging/passing of upper eightbyte with X87 class.
47 // CHECK: define %0 @f8_1()
48 // CHECK: define void @f8_2(i64 %a0.coerce0, double %a0.coerce1)
53 union u8
f8_1() { while (1) {} }
54 void f8_2(union u8 a0
) {}
56 // CHECK: define i64 @f9()
57 struct s9
{ int a
; int b
; int : 0; } f9(void) { while (1) {} }
59 // CHECK: define void @f10(i64 %a0.coerce)
60 struct s10
{ int a
; int b
; int : 0; };
61 void f10(struct s10 a0
) {}
63 // CHECK: define void @f11(%struct.s19* sret %agg.result)
64 union { long double a
; float b
; } f11() { while (1) {} }
66 // CHECK: define i32 @f12_0()
67 // CHECK: define void @f12_1(i32 %a0.coerce)
68 struct s12
{ int a
__attribute__((aligned(16))); };
69 struct s12
f12_0(void) { while (1) {} }
70 void f12_1(struct s12 a0
) {}
72 // Check that sret parameter is accounted for when checking available integer
74 // CHECK: define void @f13(%struct.s13_0* sret %agg.result, i32 %a, i32 %b, i32 %c, i32 %d, {{.*}}* byval %e, i32 %f)
76 struct s13_0
{ long long f0
[3]; };
77 struct s13_1
{ long long f0
[2]; };
78 struct s13_0
f13(int a
, int b
, int c
, int d
,
79 struct s13_1 e
, int f
) { while (1) {} }
81 // CHECK: define void @f14({{.*}}, i8 signext %X)
82 void f14(int a
, int b
, int c
, int d
, int e
, int f
, char X
) {}
84 // CHECK: define void @f15({{.*}}, i8* %X)
85 void f15(int a
, int b
, int c
, int d
, int e
, int f
, void *X
) {}
87 // CHECK: define void @f16({{.*}}, float %X)
88 void f16(float a
, float b
, float c
, float d
, float e
, float f
, float g
, float h
,
91 // CHECK: define void @f17({{.*}}, x86_fp80 %X)
92 void f17(float a
, float b
, float c
, float d
, float e
, float f
, float g
, float h
,
95 // Check for valid coercion. The struct should be passed/returned as i32, not
96 // as i64 for better code quality.
98 // CHECK: define void @f18(i32 %a, i32 %f18_arg1.coerce)
99 struct f18_s0
{ int f0
; };
100 void f18(int a
, struct f18_s0 f18_arg1
) { while (1) {} }
102 // Check byval alignment.
104 // CHECK: define void @f19(%struct.s19* byval align 16 %x)
108 void f19(struct s19 x
) {}
110 // CHECK: define void @f20(%struct.s20* byval align 32 %x)
111 struct __attribute__((aligned(32))) s20
{
115 void f20(struct s20 x
) {}
123 // CHECK: define i8* @f21(i64 %S.coerce0, i8* %S.coerce1)
124 const char *f21(struct StringRef S
) { return S
.x
+S
.Ptr
; }
127 typedef __attribute__ ((aligned(16))) struct f22s
{ unsigned long long x
[2]; } L
;
128 void f22(L x
, L y
) { }
130 // CHECK: %x = alloca{{.*}}, align 16
131 // CHECK: %y = alloca{{.*}}, align 16
143 void f23(int A
, struct f23S B
) {
144 // CHECK: define void @f23(i32 %A, i64 %B.coerce0, i32 %B.coerce1)
147 struct f24s
{ long a
; int b
; };
149 struct f23S
f24(struct f23S
*X
, struct f24s
*P2
) {
152 // CHECK: define %struct.f24s @f24(%struct.f23S* %X, %struct.f24s* %P2)
156 typedef float v4f32
__attribute__((__vector_size__(16)));
158 // CHECK: define <4 x float> @f25(<4 x float> %X)
160 // CHECK: alloca <4 x float>
162 // CHECK: store <4 x float> %X, <4 x float>*
164 // CHECK: ret <4 x float>
173 struct foo26
f26(struct foo26
*P
) {
174 // CHECK: define %struct.foo26 @f26(%struct.foo26* %P)
179 struct v4f32wrapper
{
183 struct v4f32wrapper
f27(struct v4f32wrapper X
) {
184 // CHECK: define <4 x float> @f27(<4 x float> %X.coerce)
193 void f28(struct f28c C
) {
194 // CHECK: define void @f28(double %C.coerce0, i32 %C.coerce1)
204 void f29a(struct f29a A
) {
205 // CHECK: define void @f29a(double %A.coerce0, i32 %A.coerce1)
209 struct S0
{ char f0
[8]; char f2
; char f3
; char f4
; };
210 void f30(struct S0 p_4
) {
211 // CHECK: define void @f30(i64 %p_4.coerce0, i24 %p_4.coerce1)
214 // Pass the third element as a float when followed by tail padding.
216 struct f31foo
{ float a
, b
, c
; };
217 float f31(struct f31foo X
) {
218 // CHECK: define float @f31(<2 x float> %X.coerce0, float %X.coerce1)
222 _Complex
float f32(_Complex
float A
, _Complex
float B
) {
224 // CHECK: define <2 x float> @f32(<2 x float> %A.coerce, <2 x float> %B.coerce)
230 struct f33s
{ long x
; float c
,d
; };
232 void f33(va_list X
) {
233 va_arg(X
, struct f33s
);
236 typedef unsigned long long v1i64
__attribute__((__vector_size__(8)));
239 // CHECK: define i64 @f34(i64 %arg.coerce)
240 v1i64
f34(v1i64 arg
) { return arg
; }
244 // CHECK: define i64 @f35(i64 %arg.coerce)
245 typedef unsigned long v1i64_2
__attribute__((__vector_size__(8)));
246 v1i64_2
f35(v1i64_2 arg
) { return arg
+arg
; }