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