Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 1 | // RUN: %clang_cc1 -emit-llvm %s -o - -triple=i686-pc-win32 -mconstructor-aliases -fno-rtti | FileCheck %s |
| 2 | |
| 3 | struct A { |
| 4 | A() : a(42) {} |
| 5 | A(const A &o) : a(o.a) {} |
| 6 | ~A() {} |
| 7 | int a; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 8 | }; |
| 9 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 10 | struct B { |
| 11 | A foo(A o); |
| 12 | A __cdecl bar(A o); |
| 13 | A __stdcall baz(A o); |
| 14 | A __fastcall qux(A o); |
| 15 | }; |
| 16 | |
| 17 | A B::foo(A x) { |
| 18 | return x; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 19 | } |
| 20 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 21 | // CHECK-LABEL: define x86_thiscallcc %struct.A* @"\01?foo@B@@QAE?AUA@@U2@@Z" |
| 22 | // CHECK: (%struct.B* %this, <{ %struct.A*, %struct.A }>* inalloca) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 23 | // CHECK: getelementptr inbounds <{ %struct.A*, %struct.A }>, <{ %struct.A*, %struct.A }>* %{{.*}}, i32 0, i32 0 |
| 24 | // CHECK: load %struct.A*, %struct.A** |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 25 | // CHECK: ret %struct.A* |
| 26 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 27 | A B::bar(A x) { |
| 28 | return x; |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 29 | } |
| 30 | |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 31 | // CHECK-LABEL: define %struct.A* @"\01?bar@B@@QAA?AUA@@U2@@Z" |
| 32 | // CHECK: (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 33 | // CHECK: getelementptr inbounds <{ %struct.B*, %struct.A*, %struct.A }>, <{ %struct.B*, %struct.A*, %struct.A }>* %{{.*}}, i32 0, i32 1 |
| 34 | // CHECK: load %struct.A*, %struct.A** |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 35 | // CHECK: ret %struct.A* |
| 36 | |
| 37 | A B::baz(A x) { |
| 38 | return x; |
| 39 | } |
| 40 | |
| 41 | // CHECK-LABEL: define x86_stdcallcc %struct.A* @"\01?baz@B@@QAG?AUA@@U2@@Z" |
| 42 | // CHECK: (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca) |
Pirama Arumuga Nainar | 3ea9e33 | 2015-04-08 08:57:32 -0700 | [diff] [blame] | 43 | // CHECK: getelementptr inbounds <{ %struct.B*, %struct.A*, %struct.A }>, <{ %struct.B*, %struct.A*, %struct.A }>* %{{.*}}, i32 0, i32 1 |
| 44 | // CHECK: load %struct.A*, %struct.A** |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame] | 45 | // CHECK: ret %struct.A* |
| 46 | |
| 47 | A B::qux(A x) { |
| 48 | return x; |
| 49 | } |
| 50 | |
| 51 | // CHECK-LABEL: define x86_fastcallcc void @"\01?qux@B@@QAI?AUA@@U2@@Z" |
| 52 | // CHECK: (%struct.B* inreg %this, %struct.A* inreg noalias sret %agg.result, <{ %struct.A }>* inalloca) |
| 53 | // CHECK: ret void |
| 54 | |
| 55 | int main() { |
| 56 | B b; |
| 57 | A a = b.foo(A()); |
| 58 | a = b.bar(a); |
| 59 | a = b.baz(a); |
| 60 | a = b.qux(a); |
| 61 | } |
| 62 | |
| 63 | // CHECK: call x86_thiscallcc %struct.A* @"\01?foo@B@@QAE?AUA@@U2@@Z" |
| 64 | // CHECK: (%struct.B* %{{[^,]*}}, <{ %struct.A*, %struct.A }>* inalloca %{{[^,]*}}) |
| 65 | // CHECK: call %struct.A* @"\01?bar@B@@QAA?AUA@@U2@@Z" |
| 66 | // CHECK: (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca %{{[^,]*}}) |
| 67 | // CHECK: call x86_stdcallcc %struct.A* @"\01?baz@B@@QAG?AUA@@U2@@Z" |
| 68 | // CHECK: (<{ %struct.B*, %struct.A*, %struct.A }>* inalloca %{{[^,]*}}) |
| 69 | // CHECK: call x86_fastcallcc void @"\01?qux@B@@QAI?AUA@@U2@@Z" |
| 70 | // CHECK: (%struct.B* inreg %{{[^,]*}}, %struct.A* inreg sret %{{.*}}, <{ %struct.A }>* inalloca %{{[^,]*}}) |