Aaron Ballman | 82bfa19 | 2012-10-02 14:26:08 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm < %s | FileCheck %s |
Hans Wennborg | 45d3950 | 2013-10-09 18:10:25 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm -mrtd < %s | FileCheck %s |
| 3 | // RUN: %clang_cc1 -triple i386-pc-linux -emit-llvm -fms-compatibility < %s |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 4 | |
| 5 | void __fastcall f1(void); |
| 6 | void __stdcall f2(void); |
| 7 | void __thiscall f3(void); |
| 8 | void __fastcall f4(void) { |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 9 | // CHECK-LABEL: define x86_fastcallcc void @f4() |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 10 | f1(); |
| 11 | // CHECK: call x86_fastcallcc void @f1() |
| 12 | } |
| 13 | void __stdcall f5(void) { |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 14 | // CHECK-LABEL: define x86_stdcallcc void @f5() |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 15 | f2(); |
| 16 | // CHECK: call x86_stdcallcc void @f2() |
| 17 | } |
| 18 | void __thiscall f6(void) { |
Stephen Lin | 93ab6bf | 2013-08-15 06:47:53 +0000 | [diff] [blame] | 19 | // CHECK-LABEL: define x86_thiscallcc void @f6() |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 20 | f3(); |
| 21 | // CHECK: call x86_thiscallcc void @f3() |
| 22 | } |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 23 | void __vectorcall f61(void) { |
| 24 | // CHECK-LABEL: define x86_vectorcallcc void @f61() |
| 25 | f3(); |
| 26 | // CHECK: call x86_thiscallcc void @f3() |
| 27 | } |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 28 | |
| 29 | // PR5280 |
| 30 | void (__fastcall *pf1)(void) = f1; |
| 31 | void (__stdcall *pf2)(void) = f2; |
| 32 | void (__thiscall *pf3)(void) = f3; |
| 33 | void (__fastcall *pf4)(void) = f4; |
| 34 | void (__stdcall *pf5)(void) = f5; |
| 35 | void (__thiscall *pf6)(void) = f6; |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 36 | void (__vectorcall *pf7)(void) = f61; |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 37 | |
| 38 | int main(void) { |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 39 | f4(); f5(); f6(); f61(); |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 40 | // CHECK: call x86_fastcallcc void @f4() |
| 41 | // CHECK: call x86_stdcallcc void @f5() |
| 42 | // CHECK: call x86_thiscallcc void @f6() |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 43 | // CHECK: call x86_vectorcallcc void @f61() |
| 44 | pf1(); pf2(); pf3(); pf4(); pf5(); pf6(); pf7(); |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 45 | // CHECK: call x86_fastcallcc void %{{.*}}() |
| 46 | // CHECK: call x86_stdcallcc void %{{.*}}() |
| 47 | // CHECK: call x86_thiscallcc void %{{.*}}() |
| 48 | // CHECK: call x86_fastcallcc void %{{.*}}() |
| 49 | // CHECK: call x86_stdcallcc void %{{.*}}() |
| 50 | // CHECK: call x86_thiscallcc void %{{.*}}() |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 51 | // CHECK: call x86_vectorcallcc void %{{.*}}() |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | // PR7117 |
| 56 | void __stdcall f7(foo) int foo; {} |
| 57 | void f8(void) { |
| 58 | f7(0); |
John McCall | 01f151e | 2011-09-21 08:08:30 +0000 | [diff] [blame] | 59 | // CHECK: call x86_stdcallcc void @f7(i32 0) |
Douglas Gregor | d1808f3 | 2010-05-18 17:43:51 +0000 | [diff] [blame] | 60 | } |
Hans Wennborg | 3636fb1 | 2013-10-08 21:52:56 +0000 | [diff] [blame] | 61 | |
| 62 | // PR12535 |
Hans Wennborg | 3636fb1 | 2013-10-08 21:52:56 +0000 | [diff] [blame] | 63 | void __fastcall f9(int x, int y) {}; |
| 64 | // WIN: define x86_fastcallcc void @f9({{.*}}) |
| 65 | void __fastcall f10(int x, ...) {}; |
| 66 | // WIN: define void @f10({{.*}}) |
Hans Wennborg | 45d3950 | 2013-10-09 18:10:25 +0000 | [diff] [blame] | 67 | void __stdcall f11(int x, ...) {}; |
| 68 | // WIN: define void @f11({{.*}}) |