Back out r101911 and see if it makes the bots happy.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101921 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp
index b2991ad..a21af41 100644
--- a/lib/CodeGen/CGClass.cpp
+++ b/lib/CodeGen/CGClass.cpp
@@ -1549,7 +1549,6 @@
void
CodeGenFunction::InitializeVTablePointer(BaseSubobject Base,
const CXXRecordDecl *NearestVBase,
- uint64_t BaseOffsetFromNearestVBase,
llvm::Constant *VTable,
const CXXRecordDecl *VTableClass) {
const CXXRecordDecl *RD = Base.getBase();
@@ -1577,31 +1576,21 @@
Builder.CreateConstInBoundsGEP2_64(VTable, 0, AddressPoint);
}
- llvm::Value *VTableField = LoadCXXThis();
-
// Compute where to store the address point.
- uint64_t NonVirtualOffset = BaseOffsetFromNearestVBase;
+ llvm::Value *VTableField;
+
+ if (CodeGenVTables::needsVTTParameter(CurGD) && NearestVBase) {
+ // We need to use the virtual base offset offset because the virtual base
+ // might have a different offset in the most derived class.
+ VTableField = GetAddressOfBaseClass(LoadCXXThis(), VTableClass, RD,
+ /*NullCheckValue=*/false);
+ } else {
+ const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
- llvm::Value *VirtualOffset = 0;
- if (NearestVBase) {
- if (!CodeGenVTables::needsVTTParameter(CurGD)) {
- // Just get the vbase offset in the complete class.
- const ASTRecordLayout &Layout =
- getContext().getASTRecordLayout(VTableClass);
-
- NonVirtualOffset += Layout.getVBaseClassOffset(NearestVBase);
- } else {
- // We need to use the virtual base offset offset because the virtual base
- // might have a different offset in the most derived class.
- VirtualOffset = GetVirtualBaseClassOffset(VTableField,
- VTableClass, NearestVBase);
- }
- }
-
- if (NonVirtualOffset || VirtualOffset)
+ VTableField = Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy);
VTableField =
- ApplyNonVirtualAndVirtualOffset(*this, VTableField,
- NonVirtualOffset, VirtualOffset);
+ Builder.CreateConstInBoundsGEP1_64(VTableField, Base.getBaseOffset() / 8);
+ }
// Finally, store the address point.
const llvm::Type *AddressPointPtrTy =
@@ -1613,7 +1602,6 @@
void
CodeGenFunction::InitializeVTablePointers(BaseSubobject Base,
const CXXRecordDecl *NearestVBase,
- uint64_t BaseOffsetFromNearestVBase,
bool BaseIsNonVirtualPrimaryBase,
llvm::Constant *VTable,
const CXXRecordDecl *VTableClass,
@@ -1622,8 +1610,7 @@
// been set.
if (!BaseIsNonVirtualPrimaryBase) {
// Initialize the vtable pointer for this base.
- InitializeVTablePointer(Base, NearestVBase, BaseOffsetFromNearestVBase,
- VTable, VTableClass);
+ InitializeVTablePointer(Base, NearestVBase, VTable, VTableClass);
}
const CXXRecordDecl *RD = Base.getBase();
@@ -1660,7 +1647,6 @@
InitializeVTablePointers(BaseSubobject(BaseDecl, BaseOffset),
I->isVirtual() ? BaseDecl : NearestVBase,
- I->isVirtual() ? 0 : BaseOffsetFromNearestVBase,
BaseDeclIsNonVirtualPrimaryBase,
VTable, VTableClass, VBases);
}
@@ -1677,7 +1663,6 @@
// Initialize the vtable pointers for this class and all of its bases.
VisitedVirtualBasesSetTy VBases;
InitializeVTablePointers(BaseSubobject(RD, 0), /*NearestVBase=*/0,
- /*BaseOffsetFromNearestVBase=*/0,
/*BaseIsNonVirtualPrimaryBase=*/false,
VTable, RD, VBases);
}