PR19113: Emit 'vtable' TBAA metadata when loading a vptr in a pointer-to-member-function call.

llvm-svn: 203691
This commit is contained in:
Richard Smith 2014-03-12 18:26:14 +00:00
parent 8cc04fc40d
commit 0fc7bdc821
2 changed files with 9 additions and 3 deletions

View File

@ -359,8 +359,7 @@ llvm::Value *ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
// Cast the adjusted this to a pointer to vtable pointer and load.
llvm::Type *VTableTy = Builder.getInt8PtrTy();
llvm::Value *VTable = Builder.CreateBitCast(This, VTableTy->getPointerTo());
VTable = Builder.CreateLoad(VTable, "memptr.vtable");
llvm::Value *VTable = CGF.GetVTablePtr(This, VTableTy);
// Apply the offset.
llvm::Value *VTableOffset = FnAsInt;

View File

@ -17,12 +17,19 @@ void CreateA() {
new A;
}
void CallFoo(A *a) {
void CallFoo(A *a, int (A::*fp)() const) {
a->foo();
(a->*fp)();
}
// CHECK-LABEL: @_Z7CallFoo
// CHECK: %{{.*}} = load {{.*}} !tbaa ![[NUM:[0-9]+]]
// CHECK: br i1
// CHECK: load {{.*}}, !tbaa ![[NUM]]
//
// CHECK-LABEL: @_ZN1AC2Ev
// CHECK: store {{.*}} !tbaa ![[NUM]]
//
// CHECK: [[NUM]] = metadata !{metadata [[TYPE:!.*]], metadata [[TYPE]], i64 0}
// CHECK: [[TYPE]] = metadata !{metadata !"vtable pointer", metadata !{{.*}}
// NOTBAA-NOT: = metadata !{metadata !"Simple C/C++ TBAA"}