1 // RUN: %clang_cc1 -fno-rtti -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s
3 // In each test case, we have two member pointers whose thunks have the same
4 // vtable offset and same mangling, but their prototypes conflict. The
5 // arguments and return type may differ. Therefore, we have to bitcast the
6 // function prototype. Unfortunately, if the return types differ, LLVM's
7 // optimizers can get upset.
10 struct A
{ virtual void a(int); };
11 struct B
{ virtual void b(int, int); };
14 virtual void b(int, int);
22 // CHECK-LABEL: define dso_local void @"?f@num_params@@YAXPAUC@1@@Z"(ptr noundef %c)
23 // CHECK: call x86_thiscallcc void @"??_9C@num_params@@$BA@AE"(ptr {{[^,]*}} %{{.*}}, i32 noundef 0)
24 // CHECK: call x86_thiscallcc void @"??_9C@num_params@@$BA@AE"(ptr {{[^,]*}} %{{.*}}, i32 noundef 0, i32 noundef 0)
26 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"??_9C@num_params@@$BA@AE"(ptr noundef %this, ...) {{.*}} comdat
27 // CHECK: musttail call x86_thiscallcc void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)
28 // CHECK-NEXT: ret void
30 namespace i64_return
{
31 struct A
{ virtual int a(); };
32 struct B
{ virtual long long b(); };
35 virtual long long b();
38 int x
= (c
->*(&C::a
))();
39 long long y
= (c
->*(&C::b
))();
44 // CHECK-LABEL: define dso_local noundef i64 @"?f@i64_return@@YA_JPAUC@1@@Z"(ptr noundef %c)
45 // CHECK: call x86_thiscallcc noundef i32 @"??_9C@i64_return@@$BA@AE"(ptr {{[^,]*}} %{{.*}})
46 // CHECK: call x86_thiscallcc noundef i64 @"??_9C@i64_return@@$BA@AE"(ptr {{[^,]*}} %{{.*}})
48 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"??_9C@i64_return@@$BA@AE"(ptr noundef %this, ...) {{.*}} comdat
49 // CHECK: musttail call x86_thiscallcc void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)
50 // CHECK-NEXT: ret void
53 struct Big
{ int big
[32]; };
54 struct A
{ virtual int a(); };
55 struct B
{ virtual Big
b(); };
62 Big
b((c
->*(&C::b
))());
66 // CHECK-LABEL: define dso_local void @"?f@sret@@YAXPAUC@1@@Z"(ptr noundef %c)
67 // CHECK: call x86_thiscallcc noundef i32 @"??_9C@sret@@$BA@AE"(ptr {{[^,]*}} %{{.*}})
68 // CHECK: call x86_thiscallcc void @"??_9C@sret@@$BA@AE"(ptr {{[^,]*}} %{{.*}}, ptr sret(%"struct.sret::Big") align 4 %{{.*}})
70 // CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"??_9C@sret@@$BA@AE"(ptr noundef %this, ...) {{.*}} comdat
71 // CHECK: musttail call x86_thiscallcc void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)
72 // CHECK-NEXT: ret void
74 namespace cdecl_inalloca
{
75 // Fairly evil, since now we end up doing an inalloca-style call through a
76 // thunk that doesn't use inalloca. Hopefully the stacks line up?
82 struct A
{ virtual void __cdecl
a(); };
83 struct B
{ virtual void __cdecl
b(Big
); };
85 virtual void __cdecl
a();
86 virtual void __cdecl
b(Big
);
95 // CHECK-LABEL: define dso_local void @"?f@cdecl_inalloca@@YAXPAUC@1@@Z"(ptr noundef %c)
96 // CHECK: call void @"??_9C@cdecl_inalloca@@$BA@AA"(ptr {{[^,]*}} %{{.*}})
97 // CHECK: call void @"??_9C@cdecl_inalloca@@$BA@AA"(ptr inalloca(<{ ptr, %"struct.cdecl_inalloca::Big" }>) %{{.*}})
99 // CHECK-LABEL: define linkonce_odr void @"??_9C@cdecl_inalloca@@$BA@AA"(ptr noundef %this, ...) {{.*}} comdat
100 // CHECK: musttail call void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)
101 // CHECK-NEXT: ret void