110 lines · cpp
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=ALL2// 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=ALL3// 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=ALL4// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --check-prefix=X86 --check-prefix=ALL5// 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=ALL6// 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=ALL7// RUN: %clang_cc1 -triple i686-pc-win32 -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN328// RUN: %clang_cc1 -triple x86_64-windows-msvc -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN649// RUN: %clang_cc1 -triple x86_64-uefi -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN6410// RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm -o - %s -DEXPLICITCC | FileCheck %s --check-prefix=EXPLICITCC11// RUN: %clang_cc1 -triple m68k-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=RTDCALL --check-prefix=ALL12// RUN: %clang_cc1 -triple m68k-unknown-linux-gnu -fdefault-calling-conv=rtdcall -emit-llvm -o - %s | FileCheck %s --check-prefix=RTDCALL --check-prefix=ALL13 14// CDECL: define{{.*}} void @_Z5test1v15// FASTCALL: define{{.*}} x86_fastcallcc void @_Z5test1v16// STDCALL: define{{.*}} x86_stdcallcc void @_Z5test1v17// VECTORCALL: define{{.*}} x86_vectorcallcc void @_Z5test1v18// REGCALL: define{{.*}} x86_regcallcc void @_Z17__regcall3__test1v19// RTDCALL: define{{.*}} m68k_rtdcc void @_Z5test1v20void test1() {}21 22// fastcall, stdcall, vectorcall, regcall and m68k_rtd do not support variadic functions.23// CDECL: define{{.*}} void @_Z12testVariadicz24// FASTCALL: define{{.*}} void @_Z12testVariadicz25// STDCALL: define{{.*}} void @_Z12testVariadicz26// VECTORCALL: define{{.*}} void @_Z12testVariadicz27// REGCALL: define{{.*}} void @_Z12testVariadicz28// RTDCALL: define{{.*}} void @_Z12testVariadicz29void testVariadic(...){}30 31// X86: define{{.*}} void @_Z5test2v32void __attribute__((cdecl)) test2() {}33 34// X86: define{{.*}} x86_fastcallcc void @_Z5test3v35void __attribute__((fastcall)) test3() {}36 37// X86: define{{.*}} x86_stdcallcc void @_Z5test4v38void __attribute__((stdcall)) test4() {}39 40// X86: define{{.*}} x86_vectorcallcc void @_Z5test5v41void __attribute__((vectorcall)) test5() {}42 43// X86: define{{.*}} x86_regcallcc void @_Z17__regcall3__test6v44void __attribute__((regcall)) test6() {}45 46// RTDCALL: define{{.*}} m68k_rtdcc void @_Z5test7v47void __attribute__((m68k_rtd)) test7() {}48 49// ALL: define linkonce_odr void @_ZN1A11test_memberEv50class A {51public:52 void test_member() {}53};54 55void 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 @main65int main() {66 return 1;67}68 69#ifdef WINDOWS70// WIN32: define dso_local noundef i32 @wmain71// WIN64: define dso_local noundef i32 @wmain72int wmain() {73 return 1;74}75// WIN32: define dso_local x86_stdcallcc noundef i32 @WinMain76// WIN64: define dso_local noundef i32 @WinMain77int WinMain() {78 return 1;79}80// WIN32: define dso_local x86_stdcallcc noundef i32 @wWinMain81// WIN64: define dso_local noundef i32 @wWinMain82int wWinMain() {83 return 1;84}85// WIN32: define dso_local x86_stdcallcc noundef i32 @DllMain86// WIN64: define dso_local noundef i32 @DllMain87int DllMain() {88 return 1;89}90#endif // Windows91 92#ifdef EXPLICITCC93// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @wmain94int __fastcall wmain() {95 return 1;96}97// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @WinMain98int __fastcall WinMain() {99 return 1;100}101// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @wWinMain102int __fastcall wWinMain() {103 return 1;104}105// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @DllMain106int __fastcall DllMain() {107 return 1;108}109#endif // ExplicitCC110