1 // RUN: %clang_cc1 %s -fno-rtti -triple=i686-pc-win32 -emit-llvm -o - | FileCheck --check-prefix=CHECK32 %s
2 // RUN: %clang_cc1 %s -fno-rtti -triple=x86_64-pc-win32 -emit-llvm -o - | FileCheck --check-prefix=CHECK64 %s
4 namespace byval_thunk
{
12 struct A
{ virtual void foo(Agg x
); };
13 struct B
{ virtual void foo(Agg x
); };
14 struct C
: A
, B
{ C(); virtual void foo(Agg x
); };
15 C::C() {} // force emission
17 // CHECK32-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"?foo@C@byval_thunk@@W3AEXUAgg@2@@Z"
18 // CHECK32: (ptr noundef %this, ptr inalloca(<{ %"struct.byval_thunk::Agg" }>) %0)
19 // CHECK32: getelementptr i8, ptr %{{.*}}, i32 -4
20 // CHECK32: musttail call x86_thiscallcc void @"?foo@C@byval_thunk@@UAEXUAgg@2@@Z"
21 // CHECK32: (ptr noundef %{{.*}}, ptr inalloca(<{ %"struct.byval_thunk::Agg" }>) %0)
22 // CHECK32-NEXT: ret void
24 // CHECK64-LABEL: define linkonce_odr dso_local void @"?foo@C@byval_thunk@@W7EAAXUAgg@2@@Z"
25 // CHECK64: (ptr noundef %this, ptr noundef %x)
26 // CHECK64: getelementptr i8, ptr %{{.*}}, i32 -8
27 // CHECK64: call void @"?foo@C@byval_thunk@@UEAAXUAgg@2@@Z"
28 // CHECK64: (ptr {{[^,]*}} %{{.*}}, ptr noundef %x)
33 namespace stdcall_thunk
{
41 struct A
{ virtual void __stdcall
foo(Agg x
); };
42 struct B
{ virtual void __stdcall
foo(Agg x
); };
43 struct C
: A
, B
{ C(); virtual void __stdcall
foo(Agg x
); };
44 C::C() {} // force emission
46 // CHECK32-LABEL: define linkonce_odr dso_local x86_stdcallcc void @"?foo@C@stdcall_thunk@@W3AGXUAgg@2@@Z"
47 // CHECK32: (ptr inalloca(<{ ptr, %"struct.stdcall_thunk::Agg" }>) %0)
48 // CHECK32: %[[this_slot:[^ ]*]] = getelementptr inbounds <{ ptr, %"struct.stdcall_thunk::Agg" }>, ptr %0, i32 0, i32 0
49 // CHECK32: load ptr, ptr %[[this_slot]]
50 // CHECK32: getelementptr i8, ptr %{{.*}}, i32 -4
51 // CHECK32: store ptr %{{.*}}, ptr %[[this_slot]]
52 // CHECK32: musttail call x86_stdcallcc void @"?foo@C@stdcall_thunk@@UAGXUAgg@2@@Z"
53 // CHECK32: (ptr inalloca(<{ ptr, %"struct.stdcall_thunk::Agg" }>) %0)
54 // CHECK32-NEXT: ret void
56 // CHECK64-LABEL: define linkonce_odr dso_local void @"?foo@C@stdcall_thunk@@W7EAAXUAgg@2@@Z"
57 // CHECK64: (ptr noundef %this, ptr noundef %x)
58 // CHECK64: getelementptr i8, ptr %{{.*}}, i32 -8
59 // CHECK64: call void @"?foo@C@stdcall_thunk@@UEAAXUAgg@2@@Z"
60 // CHECK64: (ptr {{[^,]*}} %{{.*}}, ptr noundef %x)
65 namespace sret_thunk
{
73 struct A
{ virtual Agg __cdecl
foo(Agg x
); };
74 struct B
{ virtual Agg __cdecl
foo(Agg x
); };
75 struct C
: A
, B
{ C(); virtual Agg __cdecl
foo(Agg x
); };
76 C::C() {} // force emission
78 // CHECK32-LABEL: define linkonce_odr dso_local ptr @"?foo@C@sret_thunk@@W3AA?AUAgg@2@U32@@Z"
79 // CHECK32: (ptr inalloca(<{ ptr, ptr, %"struct.sret_thunk::Agg" }>) %0)
80 // CHECK32: %[[this_slot:[^ ]*]] = getelementptr inbounds <{ ptr, ptr, %"struct.sret_thunk::Agg" }>, ptr %0, i32 0, i32 0
81 // CHECK32: load ptr, ptr %[[this_slot]]
82 // CHECK32: getelementptr i8, ptr %{{.*}}, i32 -4
83 // CHECK32: store ptr %{{.*}}, ptr %[[this_slot]]
84 // CHECK32: %[[rv:[^ ]*]] = musttail call ptr @"?foo@C@sret_thunk@@UAA?AUAgg@2@U32@@Z"
85 // CHECK32: (ptr inalloca(<{ ptr, ptr, %"struct.sret_thunk::Agg" }>) %0)
86 // CHECK32-NEXT: ret ptr %[[rv]]
88 // CHECK64-LABEL: define linkonce_odr dso_local void @"?foo@C@sret_thunk@@W7EAA?AUAgg@2@U32@@Z"
89 // CHECK64: (ptr noundef %this, ptr noalias sret(%"struct.sret_thunk::Agg") align 4 %agg.result, ptr noundef %x)
90 // CHECK64: getelementptr i8, ptr %{{.*}}, i32 -8
91 // CHECK64: call void @"?foo@C@sret_thunk@@UEAA?AUAgg@2@U32@@Z"
92 // CHECK64: (ptr {{[^,]*}} %{{.*}}, ptr sret(%"struct.sret_thunk::Agg") align 4 %agg.result, ptr noundef %x)
98 // FIXME: When we extend LLVM IR to allow forwarding of varargs through musttail
99 // calls, use this test.
100 namespace variadic_thunk
{
108 struct A
{ virtual void foo(Agg x
, ...); };
109 struct B
{ virtual void foo(Agg x
, ...); };
110 struct C
: A
, B
{ C(); virtual void foo(Agg x
, ...); };
111 C::C() {} // force emission