Alexey Bataev | a754718 | 2016-05-18 09:06:38 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-unknown-linux-gnu -fdefault-calling-conv=cdecl -emit-llvm -o - %s | FileCheck %s --check-prefix=CDECL --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=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=ALL |
| 4 | // RUN: %clang_cc1 -triple i486-unknown-linux-gnu -mrtd -emit-llvm -o - %s | FileCheck %s --check-prefix=STDCALL --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=ALL |
Erich Keane | a957ffb | 2017-11-02 21:08:00 +0000 | [diff] [blame] | 6 | // RUN: %clang_cc1 -triple i986-unknown-linux-gnu -fdefault-calling-conv=regcall -emit-llvm -o - %s | FileCheck %s --check-prefix=REGCALL --check-prefix=ALL |
Alexey Bataev | a754718 | 2016-05-18 09:06:38 +0000 | [diff] [blame] | 7 | |
| 8 | // CDECL: define void @_Z5test1v |
| 9 | // FASTCALL: define x86_fastcallcc void @_Z5test1v |
| 10 | // STDCALL: define x86_stdcallcc void @_Z5test1v |
| 11 | // VECTORCALL: define x86_vectorcallcc void @_Z5test1v |
Erich Keane | a957ffb | 2017-11-02 21:08:00 +0000 | [diff] [blame] | 12 | // REGCALL: define x86_regcallcc void @_Z17__regcall3__test1v |
Alexey Bataev | a754718 | 2016-05-18 09:06:38 +0000 | [diff] [blame] | 13 | void test1() {} |
| 14 | |
Erich Keane | a957ffb | 2017-11-02 21:08:00 +0000 | [diff] [blame] | 15 | // fastcall, stdcall, vectorcall and regcall do not support variadic functions. |
Erich Keane | 5759fa7 | 2017-10-24 23:12:01 +0000 | [diff] [blame] | 16 | // CDECL: define void @_Z12testVariadicz |
| 17 | // FASTCALL: define void @_Z12testVariadicz |
| 18 | // STDCALL: define void @_Z12testVariadicz |
| 19 | // VECTORCALL: define void @_Z12testVariadicz |
Erich Keane | a957ffb | 2017-11-02 21:08:00 +0000 | [diff] [blame] | 20 | // REGCALL: define void @_Z12testVariadicz |
Erich Keane | 5759fa7 | 2017-10-24 23:12:01 +0000 | [diff] [blame] | 21 | void testVariadic(...){} |
| 22 | |
Alexey Bataev | a754718 | 2016-05-18 09:06:38 +0000 | [diff] [blame] | 23 | // ALL: define void @_Z5test2v |
| 24 | void __attribute__((cdecl)) test2() {} |
| 25 | |
| 26 | // ALL: define x86_fastcallcc void @_Z5test3v |
| 27 | void __attribute__((fastcall)) test3() {} |
| 28 | |
| 29 | // ALL: define x86_stdcallcc void @_Z5test4v |
| 30 | void __attribute__((stdcall)) test4() {} |
| 31 | |
| 32 | // ALL: define x86_vectorcallcc void @_Z5test5v |
| 33 | void __attribute__((vectorcall)) test5() {} |
| 34 | |
Erich Keane | a957ffb | 2017-11-02 21:08:00 +0000 | [diff] [blame] | 35 | // ALL: define x86_regcallcc void @_Z17__regcall3__test6v |
| 36 | void __attribute__((regcall)) test6() {} |
| 37 | |
Alexey Bataev | a754718 | 2016-05-18 09:06:38 +0000 | [diff] [blame] | 38 | // ALL: define linkonce_odr void @_ZN1A11test_memberEv |
| 39 | class A { |
| 40 | public: |
| 41 | void test_member() {} |
| 42 | }; |
| 43 | |
| 44 | void test() { |
| 45 | A a; |
| 46 | a.test_member(); |
| 47 | } |
Erich Keane | a957ffb | 2017-11-02 21:08:00 +0000 | [diff] [blame] | 48 | |
| 49 | // ALL: define i32 @main |
| 50 | int main() { |
| 51 | return 1; |
| 52 | } |