1 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -o - -emit-llvm -debug-info-kind=limited %s | FileCheck %s --check-prefix=LINUX
2 // RUN: %clang_cc1 -triple x86_64-unknown-windows-msvc -o - -emit-llvm -debug-info-kind=limited %s | FileCheck %s --check-prefix=WINDOWS
3 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -o - -emit-llvm -debug-info-kind=limited %s | FileCheck %s --check-prefix=LINUX32
4 // RUN: %clang_cc1 -triple armv7--linux-gnueabihf -o - -emit-llvm -debug-info-kind=limited %s | FileCheck %s --check-prefix=ARM
5
6 // enum CallingConv {
7 // CC_C, // __attribute__((cdecl))
8 // CC_X86StdCall, // __attribute__((stdcall))
9 // CC_X86FastCall, // __attribute__((fastcall))
10 // CC_X86ThisCall, // __attribute__((thiscall))
11 // CC_X86VectorCall, // __attribute__((vectorcall))
12 // CC_X86Pascal, // __attribute__((pascal))
13 // CC_Win64, // __attribute__((ms_abi))
14 // CC_X86_64SysV, // __attribute__((sysv_abi))
15 // CC_X86RegCall, // __attribute__((regcall))
16 // CC_AAPCS, // __attribute__((pcs("aapcs")))
17 // CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp")))
18 // CC_IntelOclBicc, // __attribute__((intel_ocl_bicc))
19 // CC_SpirFunction, // default for OpenCL functions on SPIR target
20 // CC_OpenCLKernel, // inferred for OpenCL kernels
21 // CC_Swift, // __attribute__((swiftcall))
22 // CC_SwiftAsync, // __attribute__((swiftasynccall))
23 // CC_PreserveMost, // __attribute__((preserve_most))
24 // CC_PreserveAll, // __attribute__((preserve_all))
25 // CC_PreserveNone, // __attribute__((preserve_none))
26 // };
27
28 #ifdef __x86_64__
29
30 #ifdef __linux__
31 // LINUX: !DISubprogram({{.*}}"add_msabi", {{.*}}type: ![[FTY:[0-9]+]]
32 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_Win64,
add_msabi(int a,int b)33 __attribute__((ms_abi)) int add_msabi(int a, int b) {
34 return a+b;
35 }
36
37 // LINUX: !DISubprogram({{.*}}"add_regcall", {{.*}}type: ![[FTY:[0-9]+]]
38 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_X86RegCall,
add_regcall(int a,int b)39 __attribute__((regcall)) int add_regcall(int a, int b) {
40 return a+b;
41 }
42
43 // LINUX: !DISubprogram({{.*}}"add_preserve_most", {{.*}}type: ![[FTY:[0-9]+]]
44 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_PreserveMost,
add_preserve_most(int a,int b)45 __attribute__((preserve_most)) int add_preserve_most(int a, int b) {
46 return a+b;
47 }
48
49 // LINUX: !DISubprogram({{.*}}"add_preserve_all", {{.*}}type: ![[FTY:[0-9]+]]
50 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_PreserveAll,
add_preserve_all(int a,int b)51 __attribute__((preserve_all)) int add_preserve_all(int a, int b) {
52 return a+b;
53 }
54
55 // LINUX: !DISubprogram({{.*}}"add_preserve_none", {{.*}}type: ![[FTY:[0-9]+]]
56 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_PreserveNone,
add_preserve_none(int a,int b)57 __attribute__((preserve_none)) int add_preserve_none(int a, int b) {
58 return a+b;
59 }
60
61 // LINUX: !DISubprogram({{.*}}"add_swiftcall", {{.*}}type: ![[FTY:[0-9]+]]
62 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_Swift,
add_swiftcall(int a,int b)63 __attribute__((swiftcall)) int add_swiftcall(int a, int b) {
64 return a+b;
65 }
66
67 // LINUX: !DISubprogram({{.*}}"add_swiftasynccall", {{.*}}type: ![[FTY:[0-9]+]]
68 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_SwiftTail,
add_swiftasynccall(int a,int b)69 __attribute__((swiftasynccall)) int add_swiftasynccall(int a, int b) {
70 return a+b;
71 }
72
73 // LINUX: !DISubprogram({{.*}}"add_inteloclbicc", {{.*}}type: ![[FTY:[0-9]+]]
74 // LINUX: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_IntelOclBicc,
add_inteloclbicc(int a,int b)75 __attribute__((intel_ocl_bicc)) int add_inteloclbicc(int a, int b) {
76 return a+b;
77 }
78 #endif
79
80 #ifdef _WIN64
81 // WINDOWS: !DISubprogram({{.*}}"add_sysvabi", {{.*}}type: ![[FTY:[0-9]+]]
82 // WINDOWS: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_X86_64SysV,
add_sysvabi(int a,int b)83 __attribute__((sysv_abi)) int add_sysvabi(int a, int b) {
84 return a+b;
85 }
86 #endif
87
88 #endif
89
90 #ifdef __i386__
91 // LINUX32: !DISubprogram({{.*}}"add_stdcall", {{.*}}type: ![[FTY:[0-9]+]]
92 // LINUX32: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_BORLAND_stdcall,
add_stdcall(int a,int b)93 __attribute__((stdcall)) int add_stdcall(int a, int b) {
94 return a+b;
95 }
96
97 // LINUX32: !DISubprogram({{.*}}"add_fastcall", {{.*}}type: ![[FTY:[0-9]+]]
98 // LINUX32: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_BORLAND_msfastcall,
add_fastcall(int a,int b)99 __attribute__((fastcall)) int add_fastcall(int a, int b) {
100 return a+b;
101 }
102
103 // LINUX32: !DISubprogram({{.*}}"add_thiscall", {{.*}}type: ![[FTY:[0-9]+]]
104 // LINUX32: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_BORLAND_thiscall,
add_thiscall(int a,int b)105 __attribute__((thiscall)) int add_thiscall(int a, int b) {
106 return a+b;
107 }
108
109 // LINUX32: !DISubprogram({{.*}}"add_vectorcall", {{.*}}type: ![[FTY:[0-9]+]]
110 // LINUX32: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_vectorcall,
add_vectorcall(int a,int b)111 __attribute__((vectorcall)) int add_vectorcall(int a, int b) {
112 return a+b;
113 }
114
115 // LINUX32: !DISubprogram({{.*}}"add_pascal", {{.*}}type: ![[FTY:[0-9]+]]
116 // LINUX32: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_BORLAND_pascal,
add_pascal(int a,int b)117 __attribute__((pascal)) int add_pascal(int a, int b) {
118 return a+b;
119 }
120 #endif
121
122 #ifdef __arm__
123 // ARM: !DISubprogram({{.*}}"add_aapcs", {{.*}}type: ![[FTY:[0-9]+]]
124 // ARM: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_AAPCS,
add_aapcs(int a,int b)125 __attribute__((pcs("aapcs"))) int add_aapcs(int a, int b) {
126 return a+b;
127 }
128
129 // ARM: !DISubprogram({{.*}}"add_aapcs_vfp", {{.*}}type: ![[FTY:[0-9]+]]
130 // ARM: ![[FTY]] = !DISubroutineType({{.*}}cc: DW_CC_LLVM_AAPCS_VFP,
add_aapcs_vfp(int a,int b)131 __attribute__((pcs("aapcs-vfp"))) int add_aapcs_vfp(int a, int b) {
132 return a+b;
133 }
134 #endif
135