57 lines · cpp
1// Tests that we assign appropriate identifiers to indirect calls and targets2// specifically for virtual methods.3 4// RUN: %clang_cc1 -triple x86_64-unknown-linux -fexperimental-call-graph-section \5// RUN: -emit-llvm -o %t %s6// RUN: FileCheck --check-prefix=FT %s < %t7// RUN: FileCheck --check-prefix=CST %s < %t8 9////////////////////////////////////////////////////////////////////////////////10// Class definitions (check for indirect target metadata)11 12class Base {13 public:14 // FT-LABEL: define {{.*}} @_ZN4Base2vfEPc(15 // FT-SAME: {{.*}} !type [[F_TVF:![0-9]+]]16 virtual int vf(char *a) { return 0; };17 };18 19 class Derived : public Base {20 public:21 // FT: define {{.*}} @_ZN7Derived2vfEPc({{.*}} !type [[F_TVF]]22 int vf(char *a) override { return 1; };23 };24 25 // FT: [[F_TVF]] = !{i64 0, !"_ZTSFiPcE.generalized"}26 27 ////////////////////////////////////////////////////////////////////////////////28 // Callsites (check for indirect callsite operand bundles)29 30 // CST-LABEL: define {{.*}} @_Z3foov31 void foo() {32 auto B = Base();33 auto D = Derived();34 35 Base *Bptr = &B;36 Base *BptrToD = &D;37 Derived *Dptr = &D;38 39 auto FpBaseVf = &Base::vf;40 auto FpDerivedVf = &Derived::vf;41 42 // CST: call noundef i32 %{{.*}}, !callee_type [[F_TVF_CT:![0-9]+]]43 (Bptr->*FpBaseVf)(0);44 45 // CST: call noundef i32 %{{.*}}, !callee_type [[F_TVF_CT:![0-9]+]]46 (BptrToD->*FpBaseVf)(0);47 48 // CST: call noundef i32 %{{.*}}, !callee_type [[F_TVF_CT:![0-9]+]]49 (Dptr->*FpBaseVf)(0);50 51 // CST: call noundef i32 %{{.*}}, !callee_type [[F_TVF_CT:![0-9]+]]52 (Dptr->*FpDerivedVf)(0);53 }54 55 // CST: [[F_TVF_CT]] = !{[[F_TVF:![0-9]+]]}56 // CST: [[F_TVF]] = !{i64 0, !"_ZTSFiPcE.generalized"}57