[cfe-commits] r98257 - /cfe/trunk/lib/CodeGen/CGVtable.cpp
Anders Carlsson
andersca at mac.com
Thu Mar 11 08:06:20 PST 2010
Author: andersca
Date: Thu Mar 11 10:06:20 2010
New Revision: 98257
URL: http://llvm.org/viewvc/llvm-project?rev=98257&view=rev
Log:
Use the new vtable layout code for computing virtual base offset offsets.
Modified:
cfe/trunk/lib/CodeGen/CGVtable.cpp
Modified: cfe/trunk/lib/CodeGen/CGVtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVtable.cpp?rev=98257&r1=98256&r2=98257&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGVtable.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGVtable.cpp Thu Mar 11 10:06:20 2010
@@ -834,6 +834,11 @@
/// VCallAndVBaseOffsetBuilder - Class for building vcall and vbase offsets.
class VCallAndVBaseOffsetBuilder {
+public:
+ typedef llvm::DenseMap<const CXXRecordDecl *, int64_t>
+ VBaseOffsetOffsetsMapTy;
+
+private:
/// MostDerivedClass - The most derived class for which we're building vcall
/// and vbase offsets.
const CXXRecordDecl *MostDerivedClass;
@@ -856,8 +861,6 @@
/// VCallOffsets - Keeps track of vcall offsets.
VCallOffsetMap VCallOffsets;
- typedef llvm::DenseMap<const CXXRecordDecl *, int64_t>
- VBaseOffsetOffsetsMapTy;
/// VBaseOffsetOffsets - Contains the offsets of the virtual base offsets,
/// relative to the address point.
@@ -900,8 +903,8 @@
const_iterator components_begin() const { return Components.rbegin(); }
const_iterator components_end() const { return Components.rend(); }
- const VCallOffsetMap& getVCallOffsets() const { return VCallOffsets; }
- const VBaseOffsetOffsetsMapTy getVBaseOffsetOffsets() const {
+ const VCallOffsetMap &getVCallOffsets() const { return VCallOffsets; }
+ const VBaseOffsetOffsetsMapTy &getVBaseOffsetOffsets() const {
return VBaseOffsetOffsets;
}
};
@@ -1416,10 +1419,10 @@
Offset.VirtualBase);
}
- // FIXME: Once the assert in getVirtualBaseOffsetIndex is back again,
+ // FIXME: Once the assert in getVirtualBaseOffsetOffset is back again,
// we can get rid of this assert.
assert(Adjustment.VBaseOffsetOffset != 0 &&
- "Invalid base offset offset!");
+ "Invalid vbase offset offset!");
}
Adjustment.NonVirtual = Offset.NonVirtualOffset;
@@ -3453,16 +3456,15 @@
if (I != VirtualBaseClassOffsetOffsets.end())
return I->second;
- // FIXME: This seems expensive. Can we do a partial job to get
- // just this data.
- AddressPointsMapTy AddressPoints;
- OldVtableBuilder b(RD, RD, 0, CGM, false, AddressPoints);
- D1(printf("vtable %s\n", RD->getNameAsCString()));
- b.GenerateVtableForBase(RD);
- b.GenerateVtableForVBases(RD);
+ VCallAndVBaseOffsetBuilder Builder(RD, RD, /*FinalOverriders=*/0,
+ BaseSubobject(RD, 0),
+ /*BaseIsVirtual=*/false,
+ /*OffsetInLayoutClass=*/0);
- for (llvm::DenseMap<const CXXRecordDecl *, uint64_t>::iterator I =
- b.getVBIndex().begin(), E = b.getVBIndex().end(); I != E; ++I) {
+
+ for (VCallAndVBaseOffsetBuilder::VBaseOffsetOffsetsMapTy::const_iterator I =
+ Builder.getVBaseOffsetOffsets().begin(),
+ E = Builder.getVBaseOffsetOffsets().end(); I != E; ++I) {
// Insert all types.
ClassPairTy ClassPair(RD, I->first);
@@ -3470,6 +3472,7 @@
}
I = VirtualBaseClassOffsetOffsets.find(ClassPair);
+
// FIXME: The assertion below assertion currently fails with the old vtable
/// layout code if there is a non-virtual thunk adjustment in a vtable.
// Once the new layout is in place, this return should be removed.
More information about the cfe-commits
mailing list