Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / stdcall-fastcall.c
blob5014b7d48e5b9cb7904d176cfe058db2e293f8e0
1 // RUN: %clang_cc1 -triple i386-unknown-unknown -Wno-strict-prototypes -emit-llvm < %s | FileCheck %s
3 void __attribute__((fastcall)) f1(void);
4 void __attribute__((stdcall)) f2(void);
5 void __attribute__((thiscall)) f3(void);
6 void __attribute__((fastcall)) f4(void) {
7 // CHECK-LABEL: define{{.*}} x86_fastcallcc void @f4()
8 f1();
9 // CHECK: call x86_fastcallcc void @f1()
11 void __attribute__((stdcall)) f5(void) {
12 // CHECK-LABEL: define{{.*}} x86_stdcallcc void @f5()
13 f2();
14 // CHECK: call x86_stdcallcc void @f2()
16 void __attribute__((thiscall)) f6(void) {
17 // CHECK-LABEL: define{{.*}} x86_thiscallcc void @f6()
18 f3();
19 // CHECK: call x86_thiscallcc void @f3()
22 // PR5280
23 void (__attribute__((fastcall)) *pf1)(void) = f1;
24 void (__attribute__((stdcall)) *pf2)(void) = f2;
25 void (__attribute__((thiscall)) *pf3)(void) = f3;
26 void (__attribute__((fastcall)) *pf4)(void) = f4;
27 void (__attribute__((stdcall)) *pf5)(void) = f5;
28 void (__attribute__((thiscall)) *pf6)(void) = f6;
30 int main(void) {
31 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();
36 // CHECK: call x86_fastcallcc void %{{.*}}()
37 // CHECK: call x86_stdcallcc void %{{.*}}()
38 // CHECK: call x86_thiscallcc void %{{.*}}()
39 // CHECK: call x86_fastcallcc void %{{.*}}()
40 // CHECK: call x86_stdcallcc void %{{.*}}()
41 // CHECK: call x86_thiscallcc void %{{.*}}()
42 return 0;
45 // PR7117
46 void __attribute((stdcall)) f7(foo) int foo; {}
47 void f8(void) {
48 f7(0);
49 // CHECK: call x86_stdcallcc void @f7(i32 noundef 0)
52 void __attribute__((fastcall)) foo1(int y);
53 void bar1(int y) {
54 // CHECK-LABEL: define{{.*}} void @bar1
55 // CHECK: call x86_fastcallcc void @foo1(i32 inreg noundef %
56 foo1(y);
59 struct S1 {
60 int x;
62 void __attribute__((fastcall)) foo2(struct S1 y);
63 void bar2(struct S1 y) {
64 // CHECK-LABEL: define{{.*}} void @bar2
65 // CHECK: call x86_fastcallcc void @foo2(i32 inreg undef, i32 %
66 foo2(y);
69 void __attribute__((fastcall)) foo3(int *y);
70 void bar3(int *y) {
71 // CHECK-LABEL: define{{.*}} void @bar3
72 // CHECK: call x86_fastcallcc void @foo3(ptr inreg noundef %
73 foo3(y);
76 enum Enum {Eval};
77 void __attribute__((fastcall)) foo4(enum Enum y);
78 void bar4(enum Enum y) {
79 // CHECK-LABEL: define{{.*}} void @bar4
80 // CHECK: call x86_fastcallcc void @foo4(i32 inreg noundef %
81 foo4(y);
84 struct S2 {
85 int x1;
86 double x2;
87 double x3;
89 void __attribute__((fastcall)) foo5(struct S2 y);
90 void bar5(struct S2 y) {
91 // CHECK-LABEL: define{{.*}} void @bar5
92 // CHECK: call x86_fastcallcc void @foo5(ptr noundef byval(%struct.S2) align 4 %
93 foo5(y);
96 void __attribute__((fastcall)) foo6(long long y);
97 void bar6(long long y) {
98 // CHECK-LABEL: define{{.*}} void @bar6
99 // CHECK: call x86_fastcallcc void @foo6(i64 noundef %
100 foo6(y);
103 void __attribute__((fastcall)) foo7(int a, struct S1 b, int c);
104 void bar7(int a, struct S1 b, int c) {
105 // CHECK-LABEL: define{{.*}} void @bar7
106 // CHECK: call x86_fastcallcc void @foo7(i32 inreg noundef %{{.*}}, i32 %{{.*}}, i32 noundef %{{.*}}
107 foo7(a, b, c);
110 void __attribute__((fastcall)) foo8(struct S1 a, int b);
111 void bar8(struct S1 a, int b) {
112 // CHECK-LABEL: define{{.*}} void @bar8
113 // CHECK: call x86_fastcallcc void @foo8(i32 inreg undef, i32 %{{.*}}, i32 inreg noundef %
114 foo8(a, b);
117 void __attribute__((fastcall)) foo9(struct S2 a, int b);
118 void bar9(struct S2 a, int b) {
119 // CHECK-LABEL: define{{.*}} void @bar9
120 // CHECK: call x86_fastcallcc void @foo9(ptr noundef byval(%struct.S2) align 4 %{{.*}}, i32 noundef %
121 foo9(a, b);
124 void __attribute__((fastcall)) foo10(float y, int x);
125 void bar10(float y, int x) {
126 // CHECK-LABEL: define{{.*}} void @bar10
127 // CHECK: call x86_fastcallcc void @foo10(float noundef %{{.*}}, i32 inreg noundef %
128 foo10(y, x);
131 void __attribute__((fastcall)) foo11(double y, int x);
132 void bar11(double y, int x) {
133 // CHECK-LABEL: define{{.*}} void @bar11
134 // CHECK: call x86_fastcallcc void @foo11(double noundef %{{.*}}, i32 inreg noundef %
135 foo11(y, x);
138 struct S3 {
139 float x;
141 void __attribute__((fastcall)) foo12(struct S3 y, int x);
142 void bar12(struct S3 y, int x) {
143 // CHECK-LABEL: define{{.*}} void @bar12
144 // CHECK: call x86_fastcallcc void @foo12(float %{{.*}}, i32 inreg noundef %
145 foo12(y, x);
148 void __attribute__((fastcall)) foo13(long long a, int b, int c);
149 void bar13(long long a, int b, int c) {
150 // CHECK-LABEL: define{{.*}} void @bar13
151 // CHECK: call x86_fastcallcc void @foo13(i64 noundef %{{.*}}, i32 inreg noundef %{{.*}}, i32 inreg noundef %
152 foo13(a, b, c);
155 struct S2 __attribute__((fastcall)) foo14(int a) {
156 // CHECK-LABEL: define dso_local x86_fastcallcc void @foo14(ptr dead_on_unwind noalias writable sret(%struct.S2) align 4 %agg.result, i32 inreg noundef %a)
157 struct S2 r = {a};
158 return r;