Debian Codegraph @

clang/test/CodeGenCXX/default_calling_conv.cpp

raw
1 // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl -emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --check-prefix=X86 --check-prefix=ALL
2 // RUN: %clang_cc1 -triple i786-unknown-linux-gnu -target-feature +sse4.2 -fdefault-calling-conv=fastcall -emit-llvm -o - %s | FileCheck %s --check-prefix=FASTCALL --check-prefix=X86 --check-prefix=ALL
3 // RUN: %clang_cc1 -triple i486-unknown-linux-gnu -fdefault-calling-conv=stdcall -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --check-prefix=X86 --check-prefix=ALL
4 // RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --check-prefix=X86 --check-prefix=ALL
5 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s --check-prefix=VECTORCALL --check-prefix=X86 --check-prefix=ALL
6 // RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s --check-prefix=REGCALL --check-prefix=X86 --check-prefix=ALL
7 // RUN: %clang_cc1 -triple i686-pc-win32 -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN32
8 // RUN: %clang_cc1 -triple x86_64-windows-msvc -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN64
9 // RUN: %clang_cc1 -triple x86_64-uefi -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN64
10 // RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm -o - %s -DEXPLICITCC | FileCheck %s --check-prefix=EXPLICITCC
11 // RUN: %clang_cc1 -triple m68k-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=RTDCALL --check-prefix=ALL
12 // RUN: %clang_cc1 -triple m68k-unknown-linux-gnu -fdefault-calling-conv=rtdcall -emit-llvm -o - %s | FileCheck %s --check-prefix=RTDCALL --check-prefix=ALL
13
14 // CDECL: define{{.*}} void @_Z5test1v
15 // FASTCALL: define{{.*}} x86_fastcallcc void @_Z5test1v
16 // STDCALL: define{{.*}} x86_stdcallcc void @_Z5test1v
17 // VECTORCALL: define{{.*}} x86_vectorcallcc void @_Z5test1v
18 // REGCALL: define{{.*}} x86_regcallcc void @_Z17__regcall3__test1v
19 // RTDCALL: define{{.*}} m68k_rtdcc void @_Z5test1v
20 void test1() {}
21
22 // fastcall, stdcall, vectorcall, regcall and m68k_rtd do not support variadic functions.
23 // CDECL: define{{.*}} void @_Z12testVariadicz
24 // FASTCALL: define{{.*}} void @_Z12testVariadicz
25 // STDCALL: define{{.*}} void @_Z12testVariadicz
26 // VECTORCALL: define{{.*}} void @_Z12testVariadicz
27 // REGCALL: define{{.*}} void @_Z12testVariadicz
28 // RTDCALL: define{{.*}} void @_Z12testVariadicz
29 void testVariadic(...){}
30
31 // X86: define{{.*}} void @_Z5test2v
32 void __attribute__((cdecl)) test2() {}
33
34 // X86: define{{.*}} x86_fastcallcc void @_Z5test3v
35 void __attribute__((fastcall)) test3() {}
36
37 // X86: define{{.*}} x86_stdcallcc void @_Z5test4v
38 void __attribute__((stdcall)) test4() {}
39
40 // X86: define{{.*}} x86_vectorcallcc void @_Z5test5v
41 void __attribute__((vectorcall)) test5() {}
42
43 // X86: define{{.*}} x86_regcallcc void @_Z17__regcall3__test6v
44 void __attribute__((regcall)) test6() {}
45
46 // RTDCALL: define{{.*}} m68k_rtdcc void @_Z5test7v
47 void __attribute__((m68k_rtd)) test7() {}
48
49 // ALL: define linkonce_odr void @_ZN1A11test_memberEv
50 class A {
51 public:
52 void test_member() {}
53 };
54
55 void test() {
56 A a;
57 a.test_member();
58
59 // ALL: define internal void @"_ZZ{{.*}}testvENK3$_0clEi"
60 auto f = [](int b) {};
61 f(87);
62 }
63
64 // ALL: define{{.*}} i32 @main
65 int main() {
66 return 1;
67 }
68
69 #ifdef WINDOWS
70 // WIN32: define dso_local noundef i32 @wmain
71 // WIN64: define dso_local noundef i32 @wmain
72 int wmain() {
73 return 1;
74 }
75 // WIN32: define dso_local x86_stdcallcc noundef i32 @WinMain
76 // WIN64: define dso_local noundef i32 @WinMain
77 int WinMain() {
78 return 1;
79 }
80 // WIN32: define dso_local x86_stdcallcc noundef i32 @wWinMain
81 // WIN64: define dso_local noundef i32 @wWinMain
82 int wWinMain() {
83 return 1;
84 }
85 // WIN32: define dso_local x86_stdcallcc noundef i32 @DllMain
86 // WIN64: define dso_local noundef i32 @DllMain
87 int DllMain() {
88 return 1;
89 }
90 #endif // Windows
91
92 #ifdef EXPLICITCC
93 // EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @wmain
94 int __fastcall wmain() {
95 return 1;
96 }
97 // EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @WinMain
98 int __fastcall WinMain() {
99 return 1;
100 }
101 // EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @wWinMain
102 int __fastcall wWinMain() {
103 return 1;
104 }
105 // EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @DllMain
106 int __fastcall DllMain() {
107 return 1;
108 }
109 #endif // ExplicitCC