brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · 615a2e3 Raw
102 lines · cpp
1// RUN: %clang_cc1 -fno-rtti -emit-llvm -triple=i386-pc-win32 %s -o - | FileCheck %s2 3// In each test case, we have two member pointers whose thunks have the same4// vtable offset and same mangling, but their prototypes conflict.  The5// arguments and return type may differ.  Therefore, we have to bitcast the6// function prototype.  Unfortunately, if the return types differ, LLVM's7// optimizers can get upset.8 9namespace num_params {10struct A { virtual void a(int); };11struct B { virtual void b(int, int); };12struct C : A, B {13  virtual void a(int);14  virtual void b(int, int);15};16void f(C *c) {17  (c->*(&C::a))(0);18  (c->*(&C::b))(0, 0);19}20}21 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)25 26// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"??_9C@num_params@@$BA@AE"(ptr noundef %this, ...) {{.*}} comdat27// CHECK: musttail call x86_thiscallcc void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)28// CHECK-NEXT: ret void29 30namespace i64_return {31struct A { virtual int a(); };32struct B { virtual long long b(); };33struct C : A, B {34  virtual int a();35  virtual long long b();36};37long long f(C *c) {38  int x = (c->*(&C::a))();39  long long y = (c->*(&C::b))();40  return x + y;41}42}43 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 {{[^,]*}} %{{.*}})47 48// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"??_9C@i64_return@@$BA@AE"(ptr noundef %this, ...) {{.*}} comdat49// CHECK: musttail call x86_thiscallcc void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)50// CHECK-NEXT: ret void51 52namespace sret {53struct Big { int big[32]; };54struct A { virtual int a(); };55struct B { virtual Big b(); };56struct C : A, B {57  virtual int a();58  virtual Big b();59};60void f(C *c) {61  (c->*(&C::a))();62  Big b((c->*(&C::b))());63}64}65 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 dead_on_unwind writable sret(%"struct.sret::Big") align 4 %{{.*}})69 70// CHECK-LABEL: define linkonce_odr x86_thiscallcc void @"??_9C@sret@@$BA@AE"(ptr noundef %this, ...) {{.*}} comdat71// CHECK: musttail call x86_thiscallcc void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)72// CHECK-NEXT: ret void73 74namespace cdecl_inalloca {75// Fairly evil, since now we end up doing an inalloca-style call through a76// thunk that doesn't use inalloca.  Hopefully the stacks line up?77struct Big {78  Big();79  ~Big();80  int big[32];81};82struct A { virtual void __cdecl a(); };83struct B { virtual void __cdecl b(Big); };84struct C : A, B {85  virtual void __cdecl a();86  virtual void __cdecl b(Big);87};88void f(C *c) {89  Big b;90  (c->*(&C::a))();91  ((c->*(&C::b))(b));92}93}94 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" }>) %{{.*}})98 99// CHECK-LABEL: define linkonce_odr void @"??_9C@cdecl_inalloca@@$BA@AA"(ptr noundef %this, ...) {{.*}} comdat100// CHECK: musttail call void (ptr, ...) %{{.*}}(ptr noundef %{{.*}}, ...)101// CHECK-NEXT: ret void102