2020-09-17 04:51:36 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl -emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --check-prefix=ALL
|
|
|
|
// 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=ALL
|
|
|
|
// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -fdefault-calling-conv=stdcall -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
|
|
|
|
// RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --check-prefix=ALL
|
|
|
|
// RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=vectorcall -emit-llvm -o - %s | FileCheck %s --check-prefix=VECTORCALL --check-prefix=ALL
|
|
|
|
// RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s --check-prefix=REGCALL --check-prefix=ALL
|
2021-03-18 17:58:35 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-pc-win32 -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN32
|
|
|
|
// RUN: %clang_cc1 -triple x86_64-windows-msvc -fdefault-calling-conv=vectorcall -emit-llvm -o - %s -DWINDOWS | FileCheck %s --check-prefix=WIN64
|
|
|
|
// RUN: %clang_cc1 -triple i686-pc-win32 -emit-llvm -o - %s -DEXPLICITCC | FileCheck %s --check-prefix=EXPLICITCC
|
2020-09-17 04:51:36 +08:00
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// CDECL: define{{.*}} void @_Z5test1v
|
|
|
|
// FASTCALL: define{{.*}} x86_fastcallcc void @_Z5test1v
|
|
|
|
// STDCALL: define{{.*}} x86_stdcallcc void @_Z5test1v
|
|
|
|
// VECTORCALL: define{{.*}} x86_vectorcallcc void @_Z5test1v
|
|
|
|
// REGCALL: define{{.*}} x86_regcallcc void @_Z17__regcall3__test1v
|
2016-05-18 17:06:38 +08:00
|
|
|
void test1() {}
|
|
|
|
|
2017-11-03 05:08:00 +08:00
|
|
|
// fastcall, stdcall, vectorcall and regcall do not support variadic functions.
|
2020-12-31 16:27:11 +08:00
|
|
|
// CDECL: define{{.*}} void @_Z12testVariadicz
|
|
|
|
// FASTCALL: define{{.*}} void @_Z12testVariadicz
|
|
|
|
// STDCALL: define{{.*}} void @_Z12testVariadicz
|
|
|
|
// VECTORCALL: define{{.*}} void @_Z12testVariadicz
|
|
|
|
// REGCALL: define{{.*}} void @_Z12testVariadicz
|
2017-10-25 07:12:01 +08:00
|
|
|
void testVariadic(...){}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// ALL: define{{.*}} void @_Z5test2v
|
2016-05-18 17:06:38 +08:00
|
|
|
void __attribute__((cdecl)) test2() {}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// ALL: define{{.*}} x86_fastcallcc void @_Z5test3v
|
2016-05-18 17:06:38 +08:00
|
|
|
void __attribute__((fastcall)) test3() {}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// ALL: define{{.*}} x86_stdcallcc void @_Z5test4v
|
2016-05-18 17:06:38 +08:00
|
|
|
void __attribute__((stdcall)) test4() {}
|
|
|
|
|
2021-01-01 05:37:35 +08:00
|
|
|
// ALL: define{{.*}} x86_vectorcallcc void @_Z5test5v
|
2016-05-18 17:06:38 +08:00
|
|
|
void __attribute__((vectorcall)) test5() {}
|
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// ALL: define{{.*}} x86_regcallcc void @_Z17__regcall3__test6v
|
2017-11-03 05:08:00 +08:00
|
|
|
void __attribute__((regcall)) test6() {}
|
|
|
|
|
2020-02-04 02:09:39 +08:00
|
|
|
// ALL: define linkonce_odr void @_ZN1A11test_memberEv
|
2016-05-18 17:06:38 +08:00
|
|
|
class A {
|
|
|
|
public:
|
|
|
|
void test_member() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
void test() {
|
|
|
|
A a;
|
|
|
|
a.test_member();
|
|
|
|
}
|
2017-11-03 05:08:00 +08:00
|
|
|
|
2020-12-31 16:27:11 +08:00
|
|
|
// ALL: define{{.*}} i32 @main
|
2017-11-03 05:08:00 +08:00
|
|
|
int main() {
|
|
|
|
return 1;
|
|
|
|
}
|
2021-03-18 17:58:35 +08:00
|
|
|
|
|
|
|
#ifdef WINDOWS
|
2021-10-15 18:26:07 +08:00
|
|
|
// WIN32: define dso_local noundef i32 @wmain
|
|
|
|
// WIN64: define dso_local noundef i32 @wmain
|
2021-03-18 17:58:35 +08:00
|
|
|
int wmain() {
|
|
|
|
return 1;
|
|
|
|
}
|
2021-10-15 18:26:07 +08:00
|
|
|
// WIN32: define dso_local x86_stdcallcc noundef i32 @WinMain
|
|
|
|
// WIN64: define dso_local noundef i32 @WinMain
|
2021-03-18 17:58:35 +08:00
|
|
|
int WinMain() {
|
|
|
|
return 1;
|
|
|
|
}
|
2021-10-15 18:26:07 +08:00
|
|
|
// WIN32: define dso_local x86_stdcallcc noundef i32 @wWinMain
|
|
|
|
// WIN64: define dso_local noundef i32 @wWinMain
|
2021-03-18 17:58:35 +08:00
|
|
|
int wWinMain() {
|
|
|
|
return 1;
|
|
|
|
}
|
2021-10-15 18:26:07 +08:00
|
|
|
// WIN32: define dso_local x86_stdcallcc noundef i32 @DllMain
|
|
|
|
// WIN64: define dso_local noundef i32 @DllMain
|
2021-03-18 17:58:35 +08:00
|
|
|
int DllMain() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif // Windows
|
|
|
|
|
|
|
|
#ifdef EXPLICITCC
|
2021-10-15 18:26:07 +08:00
|
|
|
// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @wmain
|
2021-03-18 17:58:35 +08:00
|
|
|
int __fastcall wmain() {
|
|
|
|
return 1;
|
|
|
|
}
|
2021-10-15 18:26:07 +08:00
|
|
|
// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @WinMain
|
2021-03-18 17:58:35 +08:00
|
|
|
int __fastcall WinMain() {
|
|
|
|
return 1;
|
|
|
|
}
|
2021-10-15 18:26:07 +08:00
|
|
|
// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @wWinMain
|
2021-03-18 17:58:35 +08:00
|
|
|
int __fastcall wWinMain() {
|
|
|
|
return 1;
|
|
|
|
}
|
2021-10-15 18:26:07 +08:00
|
|
|
// EXPLICITCC: define dso_local x86_fastcallcc noundef i32 @DllMain
|
2021-03-18 17:58:35 +08:00
|
|
|
int __fastcall DllMain() {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
#endif // ExplicitCC
|