Rename CGVtableInfo to CodeGenVTables in preparation of adding another VTableInfo class.

llvm-svn: 99250
This commit is contained in:
Anders Carlsson 2010-03-23 04:11:45 +00:00
parent 86face8333
commit a864caff8c
13 changed files with 85 additions and 87 deletions

View File

@ -489,10 +489,10 @@ CodeGenModule::GetAddrOfCovariantThunk(GlobalDecl GD,
} }
void CodeGenModule::BuildThunksForVirtual(GlobalDecl GD) { void CodeGenModule::BuildThunksForVirtual(GlobalDecl GD) {
CGVtableInfo::AdjustmentVectorTy *AdjPtr = getVtableInfo().getAdjustments(GD); CodeGenVTables::AdjustmentVectorTy *AdjPtr = getVTables().getAdjustments(GD);
if (!AdjPtr) if (!AdjPtr)
return; return;
CGVtableInfo::AdjustmentVectorTy &Adj = *AdjPtr; CodeGenVTables::AdjustmentVectorTy &Adj = *AdjPtr;
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
for (unsigned i = 0; i < Adj.size(); i++) { for (unsigned i = 0; i < Adj.size(); i++) {
GlobalDecl OGD = Adj[i].first; GlobalDecl OGD = Adj[i].first;
@ -618,17 +618,17 @@ llvm::Value *
CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *This, CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *This,
const llvm::Type *Ty) { const llvm::Type *Ty) {
MD = MD->getCanonicalDecl(); MD = MD->getCanonicalDecl();
uint64_t VtableIndex = CGM.getVtableInfo().getMethodVtableIndex(MD); uint64_t VTableIndex = CGM.getVTables().getMethodVtableIndex(MD);
return ::BuildVirtualCall(*this, VtableIndex, This, Ty); return ::BuildVirtualCall(*this, VTableIndex, This, Ty);
} }
llvm::Value * llvm::Value *
CodeGenFunction::BuildVirtualCall(const CXXDestructorDecl *DD, CXXDtorType Type, CodeGenFunction::BuildVirtualCall(const CXXDestructorDecl *DD, CXXDtorType Type,
llvm::Value *&This, const llvm::Type *Ty) { llvm::Value *&This, const llvm::Type *Ty) {
DD = cast<CXXDestructorDecl>(DD->getCanonicalDecl()); DD = cast<CXXDestructorDecl>(DD->getCanonicalDecl());
uint64_t VtableIndex = uint64_t VTableIndex =
CGM.getVtableInfo().getMethodVtableIndex(GlobalDecl(DD, Type)); CGM.getVTables().getMethodVtableIndex(GlobalDecl(DD, Type));
return ::BuildVirtualCall(*this, VtableIndex, This, Ty); return ::BuildVirtualCall(*this, VTableIndex, This, Ty);
} }

View File

@ -98,7 +98,7 @@ CodeGenModule::ComputeThunkAdjustment(const CXXRecordDecl *ClassDecl,
} }
if (VBase) if (VBase)
VirtualOffset = VirtualOffset =
getVtableInfo().getVirtualBaseOffsetOffset(ClassDecl, BaseClassDecl); getVTables().getVirtualBaseOffsetOffset(ClassDecl, BaseClassDecl);
uint64_t Offset = uint64_t Offset =
ComputeNonVirtualBaseClassOffset(getContext(), Paths.front(), Start); ComputeNonVirtualBaseClassOffset(getContext(), Paths.front(), Start);
@ -471,7 +471,7 @@ void CodeGenFunction::EmitClassAggrCopyAssignment(llvm::Value *Dest,
/// GetVTTParameter - Return the VTT parameter that should be passed to a /// GetVTTParameter - Return the VTT parameter that should be passed to a
/// base constructor/destructor with virtual bases. /// base constructor/destructor with virtual bases.
static llvm::Value *GetVTTParameter(CodeGenFunction &CGF, GlobalDecl GD) { static llvm::Value *GetVTTParameter(CodeGenFunction &CGF, GlobalDecl GD) {
if (!CGVtableInfo::needsVTTParameter(GD)) { if (!CodeGenVTables::needsVTTParameter(GD)) {
// This constructor/destructor does not need a VTT parameter. // This constructor/destructor does not need a VTT parameter.
return 0; return 0;
} }
@ -486,21 +486,21 @@ static llvm::Value *GetVTTParameter(CodeGenFunction &CGF, GlobalDecl GD) {
// If the record matches the base, this is the complete ctor/dtor // If the record matches the base, this is the complete ctor/dtor
// variant calling the base variant in a class with virtual bases. // variant calling the base variant in a class with virtual bases.
if (RD == Base) { if (RD == Base) {
assert(!CGVtableInfo::needsVTTParameter(CGF.CurGD) && assert(!CodeGenVTables::needsVTTParameter(CGF.CurGD) &&
"doing no-op VTT offset in base dtor/ctor?"); "doing no-op VTT offset in base dtor/ctor?");
SubVTTIndex = 0; SubVTTIndex = 0;
} else { } else {
SubVTTIndex = CGF.CGM.getVtableInfo().getSubVTTIndex(RD, Base); SubVTTIndex = CGF.CGM.getVTables().getSubVTTIndex(RD, Base);
assert(SubVTTIndex != 0 && "Sub-VTT index must be greater than zero!"); assert(SubVTTIndex != 0 && "Sub-VTT index must be greater than zero!");
} }
if (CGVtableInfo::needsVTTParameter(CGF.CurGD)) { if (CodeGenVTables::needsVTTParameter(CGF.CurGD)) {
// A VTT parameter was passed to the constructor, use it. // A VTT parameter was passed to the constructor, use it.
VTT = CGF.LoadCXXVTT(); VTT = CGF.LoadCXXVTT();
VTT = CGF.Builder.CreateConstInBoundsGEP1_64(VTT, SubVTTIndex); VTT = CGF.Builder.CreateConstInBoundsGEP1_64(VTT, SubVTTIndex);
} else { } else {
// We're the complete constructor, so get the VTT by name. // We're the complete constructor, so get the VTT by name.
VTT = CGF.CGM.getVtableInfo().getVTT(RD); VTT = CGF.CGM.getVTables().getVTT(RD);
VTT = CGF.Builder.CreateConstInBoundsGEP2_64(VTT, 0, SubVTTIndex); VTT = CGF.Builder.CreateConstInBoundsGEP2_64(VTT, 0, SubVTTIndex);
} }
@ -1474,7 +1474,7 @@ CodeGenFunction::EmitDelegateCXXConstructorCall(const CXXConstructorDecl *Ctor,
QualType VoidPP = getContext().getPointerType(getContext().VoidPtrTy); QualType VoidPP = getContext().getPointerType(getContext().VoidPtrTy);
DelegateArgs.push_back(std::make_pair(RValue::get(VTT), VoidPP)); DelegateArgs.push_back(std::make_pair(RValue::get(VTT), VoidPP));
if (CGVtableInfo::needsVTTParameter(CurGD)) { if (CodeGenVTables::needsVTTParameter(CurGD)) {
assert(I != E && "cannot skip vtt parameter, already done with args"); assert(I != E && "cannot skip vtt parameter, already done with args");
assert(I->second == VoidPP && "skipping parameter not of vtt type"); assert(I->second == VoidPP && "skipping parameter not of vtt type");
++I; ++I;
@ -1541,7 +1541,7 @@ CodeGenFunction::GetVirtualBaseClassOffset(llvm::Value *This,
VTablePtr = Builder.CreateLoad(VTablePtr, "vtable"); VTablePtr = Builder.CreateLoad(VTablePtr, "vtable");
int64_t VBaseOffsetOffset = int64_t VBaseOffsetOffset =
CGM.getVtableInfo().getVirtualBaseOffsetOffset(ClassDecl, BaseClassDecl); CGM.getVTables().getVirtualBaseOffsetOffset(ClassDecl, BaseClassDecl);
llvm::Value *VBaseOffsetPtr = llvm::Value *VBaseOffsetPtr =
Builder.CreateConstGEP1_64(VTablePtr, VBaseOffsetOffset, "vbase.offset.ptr"); Builder.CreateConstGEP1_64(VTablePtr, VBaseOffsetOffset, "vbase.offset.ptr");
@ -1560,9 +1560,9 @@ void CodeGenFunction::InitializeVtablePtrs(const CXXRecordDecl *ClassDecl) {
if (!ClassDecl->isDynamicClass()) if (!ClassDecl->isDynamicClass())
return; return;
llvm::Constant *Vtable = CGM.getVtableInfo().getVtable(ClassDecl); llvm::Constant *VTable = CGM.getVTables().getVtable(ClassDecl);
CGVtableInfo::AddrSubMap_t& AddressPoints = CodeGenVTables::AddrSubMap_t& AddressPoints =
*(*CGM.getVtableInfo().AddressPoints[ClassDecl])[ClassDecl]; *(*CGM.getVTables().AddressPoints[ClassDecl])[ClassDecl];
llvm::Value *ThisPtr = LoadCXXThis(); llvm::Value *ThisPtr = LoadCXXThis();
const ASTRecordLayout &Layout = getContext().getASTRecordLayout(ClassDecl); const ASTRecordLayout &Layout = getContext().getASTRecordLayout(ClassDecl);
@ -1573,18 +1573,18 @@ void CodeGenFunction::InitializeVtablePtrs(const CXXRecordDecl *ClassDecl) {
CXXRecordDecl *BaseClassDecl CXXRecordDecl *BaseClassDecl
= cast<CXXRecordDecl>(Base.getType()->getAs<RecordType>()->getDecl()); = cast<CXXRecordDecl>(Base.getType()->getAs<RecordType>()->getDecl());
uint64_t Offset = Layout.getVBaseClassOffset(BaseClassDecl); uint64_t Offset = Layout.getVBaseClassOffset(BaseClassDecl);
InitializeVtablePtrsRecursive(BaseClassDecl, Vtable, AddressPoints, InitializeVtablePtrsRecursive(BaseClassDecl, VTable, AddressPoints,
ThisPtr, Offset); ThisPtr, Offset);
} }
// Store address points for non-virtual bases and current class // Store address points for non-virtual bases and current class
InitializeVtablePtrsRecursive(ClassDecl, Vtable, AddressPoints, ThisPtr, 0); InitializeVtablePtrsRecursive(ClassDecl, VTable, AddressPoints, ThisPtr, 0);
} }
void CodeGenFunction::InitializeVtablePtrsRecursive( void CodeGenFunction::InitializeVtablePtrsRecursive(
const CXXRecordDecl *ClassDecl, const CXXRecordDecl *ClassDecl,
llvm::Constant *Vtable, llvm::Constant *Vtable,
CGVtableInfo::AddrSubMap_t& AddressPoints, CodeGenVTables::AddrSubMap_t& AddressPoints,
llvm::Value *ThisPtr, llvm::Value *ThisPtr,
uint64_t Offset) { uint64_t Offset) {
if (!ClassDecl->isDynamicClass()) if (!ClassDecl->isDynamicClass())

View File

@ -608,7 +608,7 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method,
// It doesn't make sense to give a virtual destructor a vtable index, // It doesn't make sense to give a virtual destructor a vtable index,
// since a single destructor has two entries in the vtable. // since a single destructor has two entries in the vtable.
if (!isa<CXXDestructorDecl>(Method)) if (!isa<CXXDestructorDecl>(Method))
VIndex = CGM.getVtableInfo().getMethodVtableIndex(Method); VIndex = CGM.getVTables().getMethodVtableIndex(Method);
ContainingType = RecordTy; ContainingType = RecordTy;
} }
@ -666,7 +666,7 @@ CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit,
if (BI->isVirtual()) { if (BI->isVirtual()) {
// virtual base offset offset is -ve. The code generator emits dwarf // virtual base offset offset is -ve. The code generator emits dwarf
// expression where it expects +ve number. // expression where it expects +ve number.
BaseOffset = 0 - CGM.getVtableInfo().getVirtualBaseOffsetOffset(RD, Base); BaseOffset = 0 - CGM.getVTables().getVirtualBaseOffsetOffset(RD, Base);
BFlags = llvm::DIType::FlagVirtual; BFlags = llvm::DIType::FlagVirtual;
} else } else
BaseOffset = RL.getBaseClassOffset(Base); BaseOffset = RL.getBaseClassOffset(Base);

View File

@ -333,8 +333,7 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) {
llvm::Value *FuncPtr; llvm::Value *FuncPtr;
if (MD->isVirtual()) { if (MD->isVirtual()) {
int64_t Index = int64_t Index = CGF.CGM.getVTables().getMethodVtableIndex(MD);
CGF.CGM.getVtableInfo().getMethodVtableIndex(MD);
// Itanium C++ ABI 2.3: // Itanium C++ ABI 2.3:
// For a non-virtual function, this field is a simple function pointer. // For a non-virtual function, this field is a simple function pointer.

View File

@ -417,7 +417,7 @@ public:
// Get the function pointer (or index if this is a virtual function). // Get the function pointer (or index if this is a virtual function).
if (MD->isVirtual()) { if (MD->isVirtual()) {
uint64_t Index = CGM.getVtableInfo().getMethodVtableIndex(MD); uint64_t Index = CGM.getVTables().getMethodVtableIndex(MD);
// Itanium C++ ABI 2.3: // Itanium C++ ABI 2.3:
// For a non-virtual function, this field is a simple function pointer. // For a non-virtual function, this field is a simple function pointer.

View File

@ -760,7 +760,7 @@ void RTTIBuilder::BuildVMIClassTypeInfo(const CXXRecordDecl *RD) {
// subobject. For a virtual base, this is the offset in the virtual table of // subobject. For a virtual base, this is the offset in the virtual table of
// the virtual base offset for the virtual base referenced (negative). // the virtual base offset for the virtual base referenced (negative).
if (Base->isVirtual()) if (Base->isVirtual())
OffsetFlags = CGM.getVtableInfo().getVirtualBaseOffsetOffset(RD, BaseDecl); OffsetFlags = CGM.getVTables().getVirtualBaseOffsetOffset(RD, BaseDecl);
else { else {
const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD); const ASTRecordLayout &Layout = CGM.getContext().getASTRecordLayout(RD);
OffsetFlags = Layout.getBaseClassOffset(BaseDecl) / 8; OffsetFlags = Layout.getBaseClassOffset(BaseDecl) / 8;

View File

@ -29,7 +29,7 @@ class VTTBuilder {
/// BLayout - Layout for the most derived class that this vtable is being /// BLayout - Layout for the most derived class that this vtable is being
/// built for. /// built for.
const ASTRecordLayout &BLayout; const ASTRecordLayout &BLayout;
CGVtableInfo::AddrMap_t &AddressPoints; CodeGenVTables::AddrMap_t &AddressPoints;
// vtbl - A pointer to the vtable for Class. // vtbl - A pointer to the vtable for Class.
llvm::Constant *ClassVtbl; llvm::Constant *ClassVtbl;
llvm::LLVMContext &VMContext; llvm::LLVMContext &VMContext;
@ -54,13 +54,13 @@ class VTTBuilder {
llvm::Constant *&CtorVtable = CtorVtables[Base]; llvm::Constant *&CtorVtable = CtorVtables[Base];
if (!CtorVtable) { if (!CtorVtable) {
// Build the vtable. // Build the vtable.
CGVtableInfo::CtorVtableInfo Info CodeGenVTables::CtorVtableInfo Info
= CGM.getVtableInfo().getCtorVtable(Class, Base, BaseIsVirtual); = CGM.getVTables().getCtorVtable(Class, Base, BaseIsVirtual);
CtorVtable = Info.Vtable; CtorVtable = Info.Vtable;
// Add the address points for this base. // Add the address points for this base.
for (CGVtableInfo::AddressPointsMapTy::const_iterator I = for (CodeGenVTables::AddressPointsMapTy::const_iterator I =
Info.AddressPoints.begin(), E = Info.AddressPoints.end(); Info.AddressPoints.begin(), E = Info.AddressPoints.end();
I != E; ++I) { I != E; ++I) {
uint64_t &AddressPoint = uint64_t &AddressPoint =
@ -263,12 +263,12 @@ public:
CodeGenModule &cgm, bool GenerateDefinition) CodeGenModule &cgm, bool GenerateDefinition)
: Inits(inits), Class(c), CGM(cgm), : Inits(inits), Class(c), CGM(cgm),
BLayout(cgm.getContext().getASTRecordLayout(c)), BLayout(cgm.getContext().getASTRecordLayout(c)),
AddressPoints(*cgm.getVtableInfo().AddressPoints[c]), AddressPoints(*cgm.getVTables().AddressPoints[c]),
VMContext(cgm.getModule().getContext()), VMContext(cgm.getModule().getContext()),
GenerateDefinition(GenerateDefinition) { GenerateDefinition(GenerateDefinition) {
// First comes the primary virtual table pointer for the complete class... // First comes the primary virtual table pointer for the complete class...
ClassVtbl = GenerateDefinition ? CGM.getVtableInfo().getVtable(Class) : 0; ClassVtbl = GenerateDefinition ? CGM.getVTables().getVtable(Class) : 0;
llvm::Constant *Init = BuildVtablePtr(ClassVtbl, Class, Class, 0); llvm::Constant *Init = BuildVtablePtr(ClassVtbl, Class, Class, 0);
Inits.push_back(Init); Inits.push_back(Init);
@ -293,9 +293,9 @@ public:
} }
llvm::GlobalVariable * llvm::GlobalVariable *
CGVtableInfo::GenerateVTT(llvm::GlobalVariable::LinkageTypes Linkage, CodeGenVTables::GenerateVTT(llvm::GlobalVariable::LinkageTypes Linkage,
bool GenerateDefinition, bool GenerateDefinition,
const CXXRecordDecl *RD) { const CXXRecordDecl *RD) {
// Only classes that have virtual bases need a VTT. // Only classes that have virtual bases need a VTT.
if (RD->getNumVBases() == 0) if (RD->getNumVBases() == 0)
return 0; return 0;
@ -336,8 +336,8 @@ CGVtableInfo::GenerateVTT(llvm::GlobalVariable::LinkageTypes Linkage,
return GV; return GV;
} }
CGVtableInfo::CtorVtableInfo CodeGenVTables::CtorVtableInfo
CGVtableInfo::getCtorVtable(const CXXRecordDecl *RD, CodeGenVTables::getCtorVtable(const CXXRecordDecl *RD,
const BaseSubobject &Base, bool BaseIsVirtual) { const BaseSubobject &Base, bool BaseIsVirtual) {
CtorVtableInfo Info; CtorVtableInfo Info;
@ -348,14 +348,12 @@ CGVtableInfo::getCtorVtable(const CXXRecordDecl *RD,
return Info; return Info;
} }
llvm::GlobalVariable *CGVtableInfo::getVTT(const CXXRecordDecl *RD) { llvm::GlobalVariable *CodeGenVTables::getVTT(const CXXRecordDecl *RD) {
return GenerateVTT(llvm::GlobalValue::ExternalLinkage, return GenerateVTT(llvm::GlobalValue::ExternalLinkage,
/*GenerateDefinition=*/false, RD); /*GenerateDefinition=*/false, RD);
} }
bool CodeGenVTables::needsVTTParameter(GlobalDecl GD) {
bool CGVtableInfo::needsVTTParameter(GlobalDecl GD) {
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
// We don't have any virtual bases, just return early. // We don't have any virtual bases, just return early.
@ -373,8 +371,8 @@ bool CGVtableInfo::needsVTTParameter(GlobalDecl GD) {
return false; return false;
} }
uint64_t CGVtableInfo::getSubVTTIndex(const CXXRecordDecl *RD, uint64_t CodeGenVTables::getSubVTTIndex(const CXXRecordDecl *RD,
const CXXRecordDecl *Base) { const CXXRecordDecl *Base) {
ClassPairTy ClassPair(RD, Base); ClassPairTy ClassPair(RD, Base);
SubVTTIndiciesTy::iterator I = SubVTTIndiciesTy::iterator I =

View File

@ -1092,8 +1092,8 @@ public:
PrimaryBasesSetVectorTy; PrimaryBasesSetVectorTy;
private: private:
/// VtableInfo - Global vtable information. /// VTables - Global vtable information.
CGVtableInfo &VtableInfo; CodeGenVTables &VTables;
/// MostDerivedClass - The most derived class for which we're building this /// MostDerivedClass - The most derived class for which we're building this
/// vtable. /// vtable.
@ -1133,7 +1133,7 @@ private:
llvm::SmallVector<VtableComponent, 64> Components; llvm::SmallVector<VtableComponent, 64> Components;
/// AddressPoints - Address points for the vtable being built. /// AddressPoints - Address points for the vtable being built.
CGVtableInfo::AddressPointsMapTy AddressPoints; CodeGenVTables::AddressPointsMapTy AddressPoints;
/// ReturnAdjustment - A return adjustment. /// ReturnAdjustment - A return adjustment.
struct ReturnAdjustment { struct ReturnAdjustment {
@ -1367,10 +1367,10 @@ private:
} }
public: public:
VtableBuilder(CGVtableInfo &VtableInfo, const CXXRecordDecl *MostDerivedClass, VtableBuilder(CodeGenVTables &VTables, const CXXRecordDecl *MostDerivedClass,
uint64_t MostDerivedClassOffset, bool MostDerivedClassIsVirtual, uint64_t MostDerivedClassOffset, bool MostDerivedClassIsVirtual,
const CXXRecordDecl *LayoutClass) const CXXRecordDecl *LayoutClass)
: VtableInfo(VtableInfo), MostDerivedClass(MostDerivedClass), : VTables(VTables), MostDerivedClass(MostDerivedClass),
MostDerivedClassOffset(MostDerivedClassOffset), MostDerivedClassOffset(MostDerivedClassOffset),
MostDerivedClassIsVirtual(MostDerivedClassIsVirtual), MostDerivedClassIsVirtual(MostDerivedClassIsVirtual),
LayoutClass(LayoutClass), Context(MostDerivedClass->getASTContext()), LayoutClass(LayoutClass), Context(MostDerivedClass->getASTContext()),
@ -1501,8 +1501,8 @@ VtableBuilder::ComputeReturnAdjustment(BaseOffset Offset) {
VBaseOffsetOffsets.lookup(Offset.VirtualBase); VBaseOffsetOffsets.lookup(Offset.VirtualBase);
} else { } else {
Adjustment.VBaseOffsetOffset = Adjustment.VBaseOffsetOffset =
VtableInfo.getVirtualBaseOffsetOffset(Offset.DerivedClass, VTables.getVirtualBaseOffsetOffset(Offset.DerivedClass,
Offset.VirtualBase); Offset.VirtualBase);
} }
// FIXME: Once the assert in getVirtualBaseOffsetOffset is back again, // FIXME: Once the assert in getVirtualBaseOffsetOffset is back again,
@ -2133,7 +2133,7 @@ void VtableBuilder::dumpLayout(llvm::raw_ostream& Out) {
// Since an address point can be shared by multiple subobjects, we use an // Since an address point can be shared by multiple subobjects, we use an
// STL multimap. // STL multimap.
std::multimap<uint64_t, BaseSubobject> AddressPointsByIndex; std::multimap<uint64_t, BaseSubobject> AddressPointsByIndex;
for (CGVtableInfo::AddressPointsMapTy::const_iterator I = for (CodeGenVTables::AddressPointsMapTy::const_iterator I =
AddressPoints.begin(), E = AddressPoints.end(); I != E; ++I) { AddressPoints.begin(), E = AddressPoints.end(); I != E; ++I) {
const BaseSubobject& Base = I->first; const BaseSubobject& Base = I->first;
uint64_t Index = I->second; uint64_t Index = I->second;
@ -2532,7 +2532,7 @@ private:
llvm::DenseMap<CtorVtable_t, int64_t> &subAddressPoints; llvm::DenseMap<CtorVtable_t, int64_t> &subAddressPoints;
/// AddressPoints - Address points for this vtable. /// AddressPoints - Address points for this vtable.
CGVtableInfo::AddressPointsMapTy& AddressPoints; CodeGenVTables::AddressPointsMapTy& AddressPoints;
typedef CXXRecordDecl::method_iterator method_iter; typedef CXXRecordDecl::method_iterator method_iter;
const uint32_t LLVMPointerWidth; const uint32_t LLVMPointerWidth;
@ -2541,9 +2541,9 @@ private:
static llvm::DenseMap<CtorVtable_t, int64_t>& static llvm::DenseMap<CtorVtable_t, int64_t>&
AllocAddressPoint(CodeGenModule &cgm, const CXXRecordDecl *l, AllocAddressPoint(CodeGenModule &cgm, const CXXRecordDecl *l,
const CXXRecordDecl *c) { const CXXRecordDecl *c) {
CGVtableInfo::AddrMap_t *&oref = cgm.getVtableInfo().AddressPoints[l]; CodeGenVTables::AddrMap_t *&oref = cgm.getVTables().AddressPoints[l];
if (oref == 0) if (oref == 0)
oref = new CGVtableInfo::AddrMap_t; oref = new CodeGenVTables::AddrMap_t;
llvm::DenseMap<CtorVtable_t, int64_t> *&ref = (*oref)[c]; llvm::DenseMap<CtorVtable_t, int64_t> *&ref = (*oref)[c];
if (ref == 0) if (ref == 0)
@ -2756,7 +2756,7 @@ private:
public: public:
OldVtableBuilder(const CXXRecordDecl *MostDerivedClass, OldVtableBuilder(const CXXRecordDecl *MostDerivedClass,
const CXXRecordDecl *l, uint64_t lo, CodeGenModule &cgm, const CXXRecordDecl *l, uint64_t lo, CodeGenModule &cgm,
bool build, CGVtableInfo::AddressPointsMapTy& AddressPoints) bool build, CodeGenVTables::AddressPointsMapTy& AddressPoints)
: BuildVtable(build), MostDerivedClass(MostDerivedClass), LayoutClass(l), : BuildVtable(build), MostDerivedClass(MostDerivedClass), LayoutClass(l),
LayoutOffset(lo), BLayout(cgm.getContext().getASTRecordLayout(l)), LayoutOffset(lo), BLayout(cgm.getContext().getASTRecordLayout(l)),
rtti(0), VMContext(cgm.getModule().getContext()),CGM(cgm), rtti(0), VMContext(cgm.getModule().getContext()),CGM(cgm),
@ -2877,7 +2877,7 @@ public:
CXXRecordDecl *D = cast<CXXRecordDecl>(qD->getAs<RecordType>()->getDecl()); CXXRecordDecl *D = cast<CXXRecordDecl>(qD->getAs<RecordType>()->getDecl());
CXXRecordDecl *B = cast<CXXRecordDecl>(qB->getAs<RecordType>()->getDecl()); CXXRecordDecl *B = cast<CXXRecordDecl>(qB->getAs<RecordType>()->getDecl());
if (D != MostDerivedClass) if (D != MostDerivedClass)
return CGM.getVtableInfo().getVirtualBaseOffsetOffset(D, B); return CGM.getVTables().getVirtualBaseOffsetOffset(D, B);
llvm::DenseMap<const CXXRecordDecl *, Index_t>::iterator i; llvm::DenseMap<const CXXRecordDecl *, Index_t>::iterator i;
i = VBIndex.find(B); i = VBIndex.find(B);
if (i != VBIndex.end()) if (i != VBIndex.end())
@ -3464,7 +3464,7 @@ void OldVtableBuilder::AppendMethodsToVtable() {
Methods.clear(); Methods.clear();
} }
void CGVtableInfo::ComputeMethodVtableIndices(const CXXRecordDecl *RD) { void CodeGenVTables::ComputeMethodVtableIndices(const CXXRecordDecl *RD) {
// Itanium C++ ABI 2.5.2: // Itanium C++ ABI 2.5.2:
// The order of the virtual function pointers in a virtual table is the // The order of the virtual function pointers in a virtual table is the
@ -3570,7 +3570,7 @@ void CGVtableInfo::ComputeMethodVtableIndices(const CXXRecordDecl *RD) {
NumVirtualFunctionPointers[RD] = CurrentIndex; NumVirtualFunctionPointers[RD] = CurrentIndex;
} }
uint64_t CGVtableInfo::getNumVirtualFunctionPointers(const CXXRecordDecl *RD) { uint64_t CodeGenVTables::getNumVirtualFunctionPointers(const CXXRecordDecl *RD) {
llvm::DenseMap<const CXXRecordDecl *, uint64_t>::iterator I = llvm::DenseMap<const CXXRecordDecl *, uint64_t>::iterator I =
NumVirtualFunctionPointers.find(RD); NumVirtualFunctionPointers.find(RD);
if (I != NumVirtualFunctionPointers.end()) if (I != NumVirtualFunctionPointers.end())
@ -3583,7 +3583,7 @@ uint64_t CGVtableInfo::getNumVirtualFunctionPointers(const CXXRecordDecl *RD) {
return I->second; return I->second;
} }
uint64_t CGVtableInfo::getMethodVtableIndex(GlobalDecl GD) { uint64_t CodeGenVTables::getMethodVtableIndex(GlobalDecl GD) {
MethodVtableIndicesTy::iterator I = MethodVtableIndices.find(GD); MethodVtableIndicesTy::iterator I = MethodVtableIndices.find(GD);
if (I != MethodVtableIndices.end()) if (I != MethodVtableIndices.end())
return I->second; return I->second;
@ -3597,8 +3597,8 @@ uint64_t CGVtableInfo::getMethodVtableIndex(GlobalDecl GD) {
return I->second; return I->second;
} }
CGVtableInfo::AdjustmentVectorTy* CodeGenVTables::AdjustmentVectorTy*
CGVtableInfo::getAdjustments(GlobalDecl GD) { CodeGenVTables::getAdjustments(GlobalDecl GD) {
SavedAdjustmentsTy::iterator I = SavedAdjustments.find(GD); SavedAdjustmentsTy::iterator I = SavedAdjustments.find(GD);
if (I != SavedAdjustments.end()) if (I != SavedAdjustments.end())
return &I->second; return &I->second;
@ -3625,8 +3625,8 @@ CGVtableInfo::getAdjustments(GlobalDecl GD) {
return 0; return 0;
} }
int64_t CGVtableInfo::getVirtualBaseOffsetOffset(const CXXRecordDecl *RD, int64_t CodeGenVTables::getVirtualBaseOffsetOffset(const CXXRecordDecl *RD,
const CXXRecordDecl *VBase) { const CXXRecordDecl *VBase) {
ClassPairTy ClassPair(RD, VBase); ClassPairTy ClassPair(RD, VBase);
VirtualBaseClassOffsetOffsetsMapTy::iterator I = VirtualBaseClassOffsetOffsetsMapTy::iterator I =
@ -3662,20 +3662,20 @@ int64_t CGVtableInfo::getVirtualBaseOffsetOffset(const CXXRecordDecl *RD,
return I->second; return I->second;
} }
uint64_t CGVtableInfo::getVtableAddressPoint(const CXXRecordDecl *RD) { uint64_t CodeGenVTables::getVtableAddressPoint(const CXXRecordDecl *RD) {
uint64_t AddressPoint = uint64_t AddressPoint =
(*(*(CGM.getVtableInfo().AddressPoints[RD]))[RD])[std::make_pair(RD, 0)]; (*(*(CGM.getVTables().AddressPoints[RD]))[RD])[std::make_pair(RD, 0)];
return AddressPoint; return AddressPoint;
} }
llvm::GlobalVariable * llvm::GlobalVariable *
CGVtableInfo::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage, CodeGenVTables::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage,
bool GenerateDefinition, bool GenerateDefinition,
const CXXRecordDecl *LayoutClass, const CXXRecordDecl *LayoutClass,
const CXXRecordDecl *RD, uint64_t Offset, const CXXRecordDecl *RD, uint64_t Offset,
bool IsVirtual, bool IsVirtual,
AddressPointsMapTy& AddressPoints) { AddressPointsMapTy& AddressPoints) {
if (GenerateDefinition) { if (GenerateDefinition) {
if (LayoutClass == RD) { if (LayoutClass == RD) {
assert(!IsVirtual && assert(!IsVirtual &&
@ -3701,7 +3701,7 @@ CGVtableInfo::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage,
llvm::StringRef Name = OutName.str(); llvm::StringRef Name = OutName.str();
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name); llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name);
if (GV == 0 || CGM.getVtableInfo().AddressPoints[LayoutClass] == 0 || if (GV == 0 || CGM.getVTables().AddressPoints[LayoutClass] == 0 ||
GV->isDeclaration()) { GV->isDeclaration()) {
OldVtableBuilder b(RD, LayoutClass, Offset, CGM, GenerateDefinition, OldVtableBuilder b(RD, LayoutClass, Offset, CGM, GenerateDefinition,
AddressPoints); AddressPoints);
@ -3740,8 +3740,9 @@ CGVtableInfo::GenerateVtable(llvm::GlobalVariable::LinkageTypes Linkage,
return GV; return GV;
} }
void CGVtableInfo::GenerateClassData(llvm::GlobalVariable::LinkageTypes Linkage, void
const CXXRecordDecl *RD) { CodeGenVTables::GenerateClassData(llvm::GlobalVariable::LinkageTypes Linkage,
const CXXRecordDecl *RD) {
llvm::GlobalVariable *&Vtable = Vtables[RD]; llvm::GlobalVariable *&Vtable = Vtables[RD];
if (Vtable) { if (Vtable) {
assert(Vtable->getInitializer() && "Vtable doesn't have a definition!"); assert(Vtable->getInitializer() && "Vtable doesn't have a definition!");
@ -3770,7 +3771,7 @@ void CGVtableInfo::GenerateClassData(llvm::GlobalVariable::LinkageTypes Linkage,
} }
} }
llvm::GlobalVariable *CGVtableInfo::getVtable(const CXXRecordDecl *RD) { llvm::GlobalVariable *CodeGenVTables::getVtable(const CXXRecordDecl *RD) {
llvm::GlobalVariable *Vtable = Vtables.lookup(RD); llvm::GlobalVariable *Vtable = Vtables.lookup(RD);
if (!Vtable) { if (!Vtable) {
@ -3783,7 +3784,7 @@ llvm::GlobalVariable *CGVtableInfo::getVtable(const CXXRecordDecl *RD) {
return Vtable; return Vtable;
} }
void CGVtableInfo::MaybeEmitVtable(GlobalDecl GD) { void CodeGenVTables::MaybeEmitVtable(GlobalDecl GD) {
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl()); const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
const CXXRecordDecl *RD = MD->getParent(); const CXXRecordDecl *RD = MD->getParent();

View File

@ -126,7 +126,7 @@ template <> struct isPodLike<clang::CodeGen::BaseSubobject> {
namespace clang { namespace clang {
namespace CodeGen { namespace CodeGen {
class CGVtableInfo { class CodeGenVTables {
public: public:
typedef std::vector<std::pair<GlobalDecl, ThunkAdjustment> > typedef std::vector<std::pair<GlobalDecl, ThunkAdjustment> >
AdjustmentVectorTy; AdjustmentVectorTy;
@ -187,7 +187,7 @@ private:
const CXXRecordDecl *RD); const CXXRecordDecl *RD);
public: public:
CGVtableInfo(CodeGenModule &CGM) CodeGenVTables(CodeGenModule &CGM)
: CGM(CGM) { } : CGM(CGM) { }
/// needsVTTParameter - Return whether the given global decl needs a VTT /// needsVTTParameter - Return whether the given global decl needs a VTT

View File

@ -279,7 +279,7 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn) {
Args.push_back(std::make_pair(CXXThisDecl, CXXThisDecl->getType())); Args.push_back(std::make_pair(CXXThisDecl, CXXThisDecl->getType()));
// Check if we need a VTT parameter as well. // Check if we need a VTT parameter as well.
if (CGVtableInfo::needsVTTParameter(GD)) { if (CodeGenVTables::needsVTTParameter(GD)) {
// FIXME: The comment about using a fake decl above applies here too. // FIXME: The comment about using a fake decl above applies here too.
QualType T = getContext().getPointerType(getContext().VoidPtrTy); QualType T = getContext().getPointerType(getContext().VoidPtrTy);
CXXVTTDecl = CXXVTTDecl =

View File

@ -525,7 +525,7 @@ public:
void InitializeVtablePtrsRecursive(const CXXRecordDecl *ClassDecl, void InitializeVtablePtrsRecursive(const CXXRecordDecl *ClassDecl,
llvm::Constant *Vtable, llvm::Constant *Vtable,
CGVtableInfo::AddrSubMap_t& AddressPoints, CodeGenVTables::AddrSubMap_t& AddressPoints,
llvm::Value *ThisPtr, llvm::Value *ThisPtr,
uint64_t Offset); uint64_t Offset);

View File

@ -47,7 +47,7 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CodeGenOptions &CGO,
Features(C.getLangOptions()), CodeGenOpts(CGO), TheModule(M), Features(C.getLangOptions()), CodeGenOpts(CGO), TheModule(M),
TheTargetData(TD), TheTargetCodeGenInfo(0), Diags(diags), TheTargetData(TD), TheTargetCodeGenInfo(0), Diags(diags),
Types(C, M, TD, getTargetCodeGenInfo().getABIInfo()), Types(C, M, TD, getTargetCodeGenInfo().getABIInfo()),
MangleCtx(C), VtableInfo(*this), Runtime(0), MangleCtx(C), VTables(*this), Runtime(0),
MemCpyFn(0), MemMoveFn(0), MemSetFn(0), CFConstantStringClassRef(0), MemCpyFn(0), MemMoveFn(0), MemSetFn(0), CFConstantStringClassRef(0),
VMContext(M.getContext()) { VMContext(M.getContext()) {
@ -495,7 +495,7 @@ void CodeGenModule::EmitDeferred() {
if (!DeferredVtables.empty()) { if (!DeferredVtables.empty()) {
const CXXRecordDecl *RD = DeferredVtables.back(); const CXXRecordDecl *RD = DeferredVtables.back();
DeferredVtables.pop_back(); DeferredVtables.pop_back();
getVtableInfo().GenerateClassData(getVtableLinkage(RD), RD); getVTables().GenerateClassData(getVtableLinkage(RD), RD);
continue; continue;
} }
@ -715,7 +715,7 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) {
"Generating code for declaration"); "Generating code for declaration");
if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) { if (const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) {
getVtableInfo().MaybeEmitVtable(GD); getVTables().MaybeEmitVtable(GD);
if (MD->isVirtual() && MD->isOutOfLine() && if (MD->isVirtual() && MD->isOutOfLine() &&
(!isa<CXXDestructorDecl>(D) || GD.getDtorType() != Dtor_Base)) { (!isa<CXXDestructorDecl>(D) || GD.getDtorType() != Dtor_Base)) {
if (isa<CXXDestructorDecl>(D)) { if (isa<CXXDestructorDecl>(D)) {

View File

@ -93,8 +93,8 @@ class CodeGenModule : public BlockModule {
CodeGenTypes Types; CodeGenTypes Types;
MangleContext MangleCtx; MangleContext MangleCtx;
/// VtableInfo - Holds information about C++ vtables. /// VTables - Holds information about C++ vtables.
CGVtableInfo VtableInfo; CodeGenVTables VTables;
CGObjCRuntime* Runtime; CGObjCRuntime* Runtime;
CGDebugInfo* DebugInfo; CGDebugInfo* DebugInfo;
@ -181,7 +181,7 @@ public:
llvm::Module &getModule() const { return TheModule; } llvm::Module &getModule() const { return TheModule; }
CodeGenTypes &getTypes() { return Types; } CodeGenTypes &getTypes() { return Types; }
MangleContext &getMangleContext() { return MangleCtx; } MangleContext &getMangleContext() { return MangleCtx; }
CGVtableInfo &getVtableInfo() { return VtableInfo; } CodeGenVTables &getVTables() { return VTables; }
Diagnostic &getDiags() const { return Diags; } Diagnostic &getDiags() const { return Diags; }
const llvm::TargetData &getTargetData() const { return TheTargetData; } const llvm::TargetData &getTargetData() const { return TheTargetData; }
llvm::LLVMContext &getLLVMContext() { return VMContext; } llvm::LLVMContext &getLLVMContext() { return VMContext; }