blob: dac2a3a1428668d452affa0101e3cbc141216df8 [file] [log] [blame]
Aaron Ballman82bfa192012-10-02 14:26:08 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm < %s | FileCheck %s
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +00002
3void __attribute__((fastcall)) f1(void);
4void __attribute__((stdcall)) f2(void);
Douglas Gregorf813a2c2010-05-18 16:57:00 +00005void __attribute__((thiscall)) f3(void);
6void __attribute__((fastcall)) f4(void) {
7// CHECK: define x86_fastcallcc void @f4()
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +00008 f1();
Charles Davisd82bf2d2010-02-05 20:45:48 +00009// CHECK: call x86_fastcallcc void @f1()
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +000010}
Douglas Gregorf813a2c2010-05-18 16:57:00 +000011void __attribute__((stdcall)) f5(void) {
12// CHECK: define x86_stdcallcc void @f5()
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +000013 f2();
Charles Davisd82bf2d2010-02-05 20:45:48 +000014// CHECK: call x86_stdcallcc void @f2()
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +000015}
Douglas Gregorf813a2c2010-05-18 16:57:00 +000016void __attribute__((thiscall)) f6(void) {
17// CHECK: define x86_thiscallcc void @f6()
18 f3();
19// CHECK: call x86_thiscallcc void @f3()
20}
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +000021
Charles Davis16c4f3c2010-02-05 18:13:10 +000022// PR5280
23void (__attribute__((fastcall)) *pf1)(void) = f1;
24void (__attribute__((stdcall)) *pf2)(void) = f2;
Douglas Gregorf813a2c2010-05-18 16:57:00 +000025void (__attribute__((thiscall)) *pf3)(void) = f3;
26void (__attribute__((fastcall)) *pf4)(void) = f4;
27void (__attribute__((stdcall)) *pf5)(void) = f5;
28void (__attribute__((thiscall)) *pf6)(void) = f6;
Charles Davis16c4f3c2010-02-05 18:13:10 +000029
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +000030int main(void) {
Douglas Gregorf813a2c2010-05-18 16:57:00 +000031 f4(); f5(); f6();
32 // CHECK: call x86_fastcallcc void @f4()
33 // CHECK: call x86_stdcallcc void @f5()
34 // CHECK: call x86_thiscallcc void @f6()
35 pf1(); pf2(); pf3(); pf4(); pf5(); pf6();
John McCall04a67a62010-02-05 21:31:56 +000036 // CHECK: call x86_fastcallcc void %{{.*}}()
37 // CHECK: call x86_stdcallcc void %{{.*}}()
Douglas Gregorf813a2c2010-05-18 16:57:00 +000038 // CHECK: call x86_thiscallcc void %{{.*}}()
John McCall04a67a62010-02-05 21:31:56 +000039 // CHECK: call x86_fastcallcc void %{{.*}}()
40 // CHECK: call x86_stdcallcc void %{{.*}}()
Douglas Gregorf813a2c2010-05-18 16:57:00 +000041 // CHECK: call x86_thiscallcc void %{{.*}}()
Anton Korobeynikovf1c9c092008-11-11 20:21:14 +000042 return 0;
43}
44
Eli Friedman9a0fcfe2010-05-17 02:50:18 +000045// PR7117
Douglas Gregorf813a2c2010-05-18 16:57:00 +000046void __attribute((stdcall)) f7(foo) int foo; {}
47void f8(void) {
48 f7(0);
John McCall01f151e2011-09-21 08:08:30 +000049 // CHECK: call x86_stdcallcc void @f7(i32 0)
Eli Friedman9a0fcfe2010-05-17 02:50:18 +000050}
Rafael Espindolab6932692012-10-24 01:58:58 +000051
52void __attribute__((fastcall)) foo1(int y);
53void bar1(int y) {
54 // CHECK: define void @bar1
55 // CHECK: call x86_fastcallcc void @foo1(i32 inreg %
56 foo1(y);
57}
58
59struct S1 {
60 int x;
61};
62void __attribute__((fastcall)) foo2(struct S1 y);
63void bar2(struct S1 y) {
64 // CHECK: define void @bar2
65 // CHECK: call x86_fastcallcc void @foo2(i32 %
66 foo2(y);
67}
68
69void __attribute__((fastcall)) foo3(int *y);
70void bar3(int *y) {
71 // CHECK: define void @bar3
72 // CHECK: call x86_fastcallcc void @foo3(i32* inreg %
73 foo3(y);
74}
75
76enum Enum {Eval};
77void __attribute__((fastcall)) foo4(enum Enum y);
78void bar4(enum Enum y) {
79 // CHECK: define void @bar4
80 // CHECK: call x86_fastcallcc void @foo4(i32 inreg %
81 foo4(y);
82}
83
84struct S2 {
85 int x1;
86 double x2;
87 double x3;
88};
89void __attribute__((fastcall)) foo5(struct S2 y);
90void bar5(struct S2 y) {
91 // CHECK: define void @bar5
92 // CHECK: call x86_fastcallcc void @foo5(%struct.S2* byval align 4 %
93 foo5(y);
94}
95
96void __attribute__((fastcall)) foo6(long long y);
97void bar6(long long y) {
98 // CHECK: define void @bar6
99 // CHECK: call x86_fastcallcc void @foo6(i64 %
100 foo6(y);
101}
102
103void __attribute__((fastcall)) foo7(int a, struct S1 b, int c);
104void bar7(int a, struct S1 b, int c) {
105 // CHECK: define void @bar7
106 // CHECK: call x86_fastcallcc void @foo7(i32 inreg %{{.*}}, i32 %{{.*}}, i32 %{{.*}}
107 foo7(a, b, c);
108}
109
110void __attribute__((fastcall)) foo8(struct S1 a, int b);
111void bar8(struct S1 a, int b) {
112 // CHECK: define void @bar8
113 // CHECK: call x86_fastcallcc void @foo8(i32 %{{.*}}, i32 inreg %
114 foo8(a, b);
115}
116
117void __attribute__((fastcall)) foo9(struct S2 a, int b);
118void bar9(struct S2 a, int b) {
119 // CHECK: define void @bar9
120 // CHECK: call x86_fastcallcc void @foo9(%struct.S2* byval align 4 %{{.*}}, i32 %
121 foo9(a, b);
122}
123
124void __attribute__((fastcall)) foo10(float y, int x);
125void bar10(float y, int x) {
126 // CHECK: define void @bar10
127 // CHECK: call x86_fastcallcc void @foo10(float %{{.*}}, i32 inreg %
128 foo10(y, x);
129}
130
131void __attribute__((fastcall)) foo11(double y, int x);
132void bar11(double y, int x) {
133 // CHECK: define void @bar11
134 // CHECK: call x86_fastcallcc void @foo11(double %{{.*}}, i32 inreg %
135 foo11(y, x);
136}
137
138struct S3 {
139 float x;
140};
141void __attribute__((fastcall)) foo12(struct S3 y, int x);
142void bar12(struct S3 y, int x) {
143 // CHECK: define void @bar12
144 // CHECK: call x86_fastcallcc void @foo12(float %{{.*}}, i32 inreg %
145 foo12(y, x);
146}