[cfe-commits] r102888 - /cfe/trunk/lib/CodeGen/CGClass.cpp
Anders Carlsson
andersca at mac.com
Sun May 2 17:29:58 PDT 2010
Author: andersca
Date: Sun May 2 19:29:58 2010
New Revision: 102888
URL: http://llvm.org/viewvc/llvm-project?rev=102888&view=rev
Log:
Get rid of the last caller of OldGetAddressOfBaseClass.
Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=102888&r1=102887&r2=102888&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Sun May 2 19:29:58 2010
@@ -1402,19 +1402,27 @@
}
// Compute where to store the address point.
- llvm::Value *VTableField;
+ llvm::Value *VirtualOffset = 0;
+ uint64_t NonVirtualOffset = 0;
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 = OldGetAddressOfBaseClass(LoadCXXThis(), VTableClass, RD);
+ VirtualOffset = GetVirtualBaseClassOffset(LoadCXXThis(), VTableClass,
+ NearestVBase);
+ NonVirtualOffset = OffsetFromNearestVBase / 8;
} else {
- const llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
-
- VTableField = Builder.CreateBitCast(LoadCXXThis(), Int8PtrTy);
- VTableField =
- Builder.CreateConstInBoundsGEP1_64(VTableField, Base.getBaseOffset() / 8);
+ // We can just use the base offset in the complete class.
+ NonVirtualOffset = Base.getBaseOffset() / 8;
}
+
+ // Apply the offsets.
+ llvm::Value *VTableField = LoadCXXThis();
+
+ if (NonVirtualOffset || VirtualOffset)
+ VTableField = ApplyNonVirtualAndVirtualOffset(*this, VTableField,
+ NonVirtualOffset,
+ VirtualOffset);
// Finally, store the address point.
const llvm::Type *AddressPointPtrTy =
@@ -1471,7 +1479,7 @@
BaseOffset = Base.getBaseOffset() + Layout.getBaseClassOffset(BaseDecl);
BaseOffsetFromNearestVBase =
- BaseOffsetFromNearestVBase + Layout.getBaseClassOffset(BaseDecl);
+ OffsetFromNearestVBase + Layout.getBaseClassOffset(BaseDecl);
BaseDeclIsNonVirtualPrimaryBase = Layout.getPrimaryBase() == BaseDecl;
}
More information about the cfe-commits
mailing list