1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm < %s | FileCheck %s
2*f4a2713aSLionel Sambuc
3*f4a2713aSLionel Sambuc void __attribute__((fastcall)) f1(void);
4*f4a2713aSLionel Sambuc void __attribute__((stdcall)) f2(void);
5*f4a2713aSLionel Sambuc void __attribute__((thiscall)) f3(void);
f4(void)6*f4a2713aSLionel Sambuc void __attribute__((fastcall)) f4(void) {
7*f4a2713aSLionel Sambuc // CHECK-LABEL: define x86_fastcallcc void @f4()
8*f4a2713aSLionel Sambuc f1();
9*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @f1()
10*f4a2713aSLionel Sambuc }
f5(void)11*f4a2713aSLionel Sambuc void __attribute__((stdcall)) f5(void) {
12*f4a2713aSLionel Sambuc // CHECK-LABEL: define x86_stdcallcc void @f5()
13*f4a2713aSLionel Sambuc f2();
14*f4a2713aSLionel Sambuc // CHECK: call x86_stdcallcc void @f2()
15*f4a2713aSLionel Sambuc }
f6(void)16*f4a2713aSLionel Sambuc void __attribute__((thiscall)) f6(void) {
17*f4a2713aSLionel Sambuc // CHECK-LABEL: define x86_thiscallcc void @f6()
18*f4a2713aSLionel Sambuc f3();
19*f4a2713aSLionel Sambuc // CHECK: call x86_thiscallcc void @f3()
20*f4a2713aSLionel Sambuc }
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc // PR5280
23*f4a2713aSLionel Sambuc void (__attribute__((fastcall)) *pf1)(void) = f1;
24*f4a2713aSLionel Sambuc void (__attribute__((stdcall)) *pf2)(void) = f2;
25*f4a2713aSLionel Sambuc void (__attribute__((thiscall)) *pf3)(void) = f3;
26*f4a2713aSLionel Sambuc void (__attribute__((fastcall)) *pf4)(void) = f4;
27*f4a2713aSLionel Sambuc void (__attribute__((stdcall)) *pf5)(void) = f5;
28*f4a2713aSLionel Sambuc void (__attribute__((thiscall)) *pf6)(void) = f6;
29*f4a2713aSLionel Sambuc
main(void)30*f4a2713aSLionel Sambuc int main(void) {
31*f4a2713aSLionel Sambuc f4(); f5(); f6();
32*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @f4()
33*f4a2713aSLionel Sambuc // CHECK: call x86_stdcallcc void @f5()
34*f4a2713aSLionel Sambuc // CHECK: call x86_thiscallcc void @f6()
35*f4a2713aSLionel Sambuc pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
36*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void %{{.*}}()
37*f4a2713aSLionel Sambuc // CHECK: call x86_stdcallcc void %{{.*}}()
38*f4a2713aSLionel Sambuc // CHECK: call x86_thiscallcc void %{{.*}}()
39*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void %{{.*}}()
40*f4a2713aSLionel Sambuc // CHECK: call x86_stdcallcc void %{{.*}}()
41*f4a2713aSLionel Sambuc // CHECK: call x86_thiscallcc void %{{.*}}()
42*f4a2713aSLionel Sambuc return 0;
43*f4a2713aSLionel Sambuc }
44*f4a2713aSLionel Sambuc
45*f4a2713aSLionel Sambuc // PR7117
46*f4a2713aSLionel Sambuc void __attribute((stdcall)) f7(foo) int foo; {}
f8(void)47*f4a2713aSLionel Sambuc void f8(void) {
48*f4a2713aSLionel Sambuc f7(0);
49*f4a2713aSLionel Sambuc // CHECK: call x86_stdcallcc void @f7(i32 0)
50*f4a2713aSLionel Sambuc }
51*f4a2713aSLionel Sambuc
52*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo1(int y);
bar1(int y)53*f4a2713aSLionel Sambuc void bar1(int y) {
54*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar1
55*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo1(i32 inreg %
56*f4a2713aSLionel Sambuc foo1(y);
57*f4a2713aSLionel Sambuc }
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc struct S1 {
60*f4a2713aSLionel Sambuc int x;
61*f4a2713aSLionel Sambuc };
62*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo2(struct S1 y);
bar2(struct S1 y)63*f4a2713aSLionel Sambuc void bar2(struct S1 y) {
64*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar2
65*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo2(i32 inreg undef, i32 %
66*f4a2713aSLionel Sambuc foo2(y);
67*f4a2713aSLionel Sambuc }
68*f4a2713aSLionel Sambuc
69*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo3(int *y);
bar3(int * y)70*f4a2713aSLionel Sambuc void bar3(int *y) {
71*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar3
72*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo3(i32* inreg %
73*f4a2713aSLionel Sambuc foo3(y);
74*f4a2713aSLionel Sambuc }
75*f4a2713aSLionel Sambuc
76*f4a2713aSLionel Sambuc enum Enum {Eval};
77*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo4(enum Enum y);
bar4(enum Enum y)78*f4a2713aSLionel Sambuc void bar4(enum Enum y) {
79*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar4
80*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo4(i32 inreg %
81*f4a2713aSLionel Sambuc foo4(y);
82*f4a2713aSLionel Sambuc }
83*f4a2713aSLionel Sambuc
84*f4a2713aSLionel Sambuc struct S2 {
85*f4a2713aSLionel Sambuc int x1;
86*f4a2713aSLionel Sambuc double x2;
87*f4a2713aSLionel Sambuc double x3;
88*f4a2713aSLionel Sambuc };
89*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo5(struct S2 y);
bar5(struct S2 y)90*f4a2713aSLionel Sambuc void bar5(struct S2 y) {
91*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar5
92*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo5(%struct.S2* byval align 4 %
93*f4a2713aSLionel Sambuc foo5(y);
94*f4a2713aSLionel Sambuc }
95*f4a2713aSLionel Sambuc
96*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo6(long long y);
bar6(long long y)97*f4a2713aSLionel Sambuc void bar6(long long y) {
98*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar6
99*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo6(i64 %
100*f4a2713aSLionel Sambuc foo6(y);
101*f4a2713aSLionel Sambuc }
102*f4a2713aSLionel Sambuc
103*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo7(int a, struct S1 b, int c);
bar7(int a,struct S1 b,int c)104*f4a2713aSLionel Sambuc void bar7(int a, struct S1 b, int c) {
105*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar7
106*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo7(i32 inreg %{{.*}}, i32 %{{.*}}, i32 %{{.*}}
107*f4a2713aSLionel Sambuc foo7(a, b, c);
108*f4a2713aSLionel Sambuc }
109*f4a2713aSLionel Sambuc
110*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo8(struct S1 a, int b);
bar8(struct S1 a,int b)111*f4a2713aSLionel Sambuc void bar8(struct S1 a, int b) {
112*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar8
113*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo8(i32 inreg undef, i32 %{{.*}}, i32 inreg %
114*f4a2713aSLionel Sambuc foo8(a, b);
115*f4a2713aSLionel Sambuc }
116*f4a2713aSLionel Sambuc
117*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo9(struct S2 a, int b);
bar9(struct S2 a,int b)118*f4a2713aSLionel Sambuc void bar9(struct S2 a, int b) {
119*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar9
120*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo9(%struct.S2* byval align 4 %{{.*}}, i32 %
121*f4a2713aSLionel Sambuc foo9(a, b);
122*f4a2713aSLionel Sambuc }
123*f4a2713aSLionel Sambuc
124*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo10(float y, int x);
bar10(float y,int x)125*f4a2713aSLionel Sambuc void bar10(float y, int x) {
126*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar10
127*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo10(float %{{.*}}, i32 inreg %
128*f4a2713aSLionel Sambuc foo10(y, x);
129*f4a2713aSLionel Sambuc }
130*f4a2713aSLionel Sambuc
131*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo11(double y, int x);
bar11(double y,int x)132*f4a2713aSLionel Sambuc void bar11(double y, int x) {
133*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar11
134*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo11(double %{{.*}}, i32 inreg %
135*f4a2713aSLionel Sambuc foo11(y, x);
136*f4a2713aSLionel Sambuc }
137*f4a2713aSLionel Sambuc
138*f4a2713aSLionel Sambuc struct S3 {
139*f4a2713aSLionel Sambuc float x;
140*f4a2713aSLionel Sambuc };
141*f4a2713aSLionel Sambuc void __attribute__((fastcall)) foo12(struct S3 y, int x);
bar12(struct S3 y,int x)142*f4a2713aSLionel Sambuc void bar12(struct S3 y, int x) {
143*f4a2713aSLionel Sambuc // CHECK-LABEL: define void @bar12
144*f4a2713aSLionel Sambuc // CHECK: call x86_fastcallcc void @foo12(float %{{.*}}, i32 inreg %
145*f4a2713aSLionel Sambuc foo12(y, x);
146*f4a2713aSLionel Sambuc }
147