summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-09-26 01:56:36 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-09-26 01:56:36 +0000
commit71c26936a018eabf024514893011b731ddf933b3 (patch)
tree425721c02ffa0fe7f8c7e10bcfc7c06ce4581613 /clang/lib/CodeGen
parenta834166e48f094b30b940fa04033016a9241ab54 (diff)
downloadbcm5719-llvm-71c26936a018eabf024514893011b731ddf933b3.tar.gz
bcm5719-llvm-71c26936a018eabf024514893011b731ddf933b3.zip
Remove CodeGenVTables::ComputeVTableRelatedInformation dependency on CodeGen
llvm-svn: 140503
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGVTT.cpp3
-rw-r--r--clang/lib/CodeGen/CGVTables.cpp42
-rw-r--r--clang/lib/CodeGen/CGVTables.h14
3 files changed, 26 insertions, 33 deletions
diff --git a/clang/lib/CodeGen/CGVTT.cpp b/clang/lib/CodeGen/CGVTT.cpp
index c7d1083cc22..e3c085a29d8 100644
--- a/clang/lib/CodeGen/CGVTT.cpp
+++ b/clang/lib/CodeGen/CGVTT.cpp
@@ -107,7 +107,8 @@ llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {
Out.flush();
StringRef Name = OutName.str();
- ComputeVTableRelatedInformation(RD, /*VTableRequired=*/true);
+ // This will also defer the definition of the VTT.
+ (void) GetAddrOfVTable(RD);
VTTBuilder Builder(CGM.getContext(), RD, /*GenerateDefinition=*/false);
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index b444c26cfb9..cd3a45ddafe 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -2956,7 +2956,7 @@ void CodeGenVTables::EmitThunks(GlobalDecl GD)
const CXXRecordDecl *RD = MD->getParent();
// Compute VTable related info for this class.
- ComputeVTableRelatedInformation(RD, false);
+ ComputeVTableRelatedInformation(RD);
ThunksMapTy::const_iterator I = Thunks.find(MD);
if (I == Thunks.end()) {
@@ -2969,20 +2969,11 @@ void CodeGenVTables::EmitThunks(GlobalDecl GD)
EmitThunk(GD, ThunkInfoVector[I], /*UseAvailableExternallyLinkage=*/false);
}
-void CodeGenVTables::ComputeVTableRelatedInformation(const CXXRecordDecl *RD,
- bool RequireVTable) {
- VTableLayoutData &Entry = VTableLayoutMap[RD];
+void CodeGenVTables::ComputeVTableRelatedInformation(const CXXRecordDecl *RD) {
+ uint64_t *&Entry = VTableLayoutMap[RD];
- // We may need to generate a definition for this vtable.
- if (RequireVTable && !Entry.getInt()) {
- if (ShouldEmitVTableInThisTU(RD))
- CGM.DeferredVTables.push_back(RD);
-
- Entry.setInt(true);
- }
-
// Check if we've computed this information before.
- if (Entry.getPointer())
+ if (Entry)
return;
VTableBuilder Builder(VTContext, RD, CharUnits::Zero(),
@@ -2998,7 +2989,7 @@ void CodeGenVTables::ComputeVTableRelatedInformation(const CXXRecordDecl *RD,
uint64_t *LayoutData = new uint64_t[NumVTableComponents + 1];
if (IsAppleKext)
LayoutData[NumVTableComponents] = 0;
- Entry.setPointer(LayoutData);
+ Entry = LayoutData;
// Store the number of components.
LayoutData[0] = NumVTableComponents;
@@ -3170,23 +3161,31 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD,
}
llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTable(const CXXRecordDecl *RD) {
+ llvm::GlobalVariable *&VTable = VTables[RD];
+ if (VTable)
+ return VTable;
+
+ // We may need to generate a definition for this vtable.
+ if (ShouldEmitVTableInThisTU(RD))
+ CGM.DeferredVTables.push_back(RD);
+
llvm::SmallString<256> OutName;
llvm::raw_svector_ostream Out(OutName);
CGM.getCXXABI().getMangleContext().mangleCXXVTable(RD, Out);
Out.flush();
StringRef Name = OutName.str();
- ComputeVTableRelatedInformation(RD, /*VTableRequired=*/true);
+ ComputeVTableRelatedInformation(RD);
llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(CGM.getLLVMContext());
llvm::ArrayType *ArrayType =
llvm::ArrayType::get(Int8PtrTy, getNumVTableComponents(RD));
- llvm::GlobalVariable *GV =
+ VTable =
CGM.CreateOrReplaceCXXRuntimeVariable(Name, ArrayType,
llvm::GlobalValue::ExternalLinkage);
- GV->setUnnamedAddr(true);
- return GV;
+ VTable->setUnnamedAddr(true);
+ return VTable;
}
void
@@ -3279,13 +3278,10 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
void
CodeGenVTables::GenerateClassData(llvm::GlobalVariable::LinkageTypes Linkage,
const CXXRecordDecl *RD) {
- llvm::GlobalVariable *&VTable = VTables[RD];
- if (VTable) {
- assert(VTable->getInitializer() && "VTable doesn't have a definition!");
+ llvm::GlobalVariable *VTable = GetAddrOfVTable(RD);
+ if (VTable->hasInitializer())
return;
- }
- VTable = GetAddrOfVTable(RD);
EmitVTableDefinition(VTable, Linkage, RD);
if (RD->getNumVBases()) {
diff --git a/clang/lib/CodeGen/CGVTables.h b/clang/lib/CodeGen/CGVTables.h
index 6e96be7219b..a29670b4585 100644
--- a/clang/lib/CodeGen/CGVTables.h
+++ b/clang/lib/CodeGen/CGVTables.h
@@ -89,11 +89,8 @@ class CodeGenVTables {
/// Thunks - Contains all thunks that a given method decl will need.
ThunksMapTy Thunks;
- // The layout entry and a bool indicating whether we've actually emitted
- // the vtable.
- typedef llvm::PointerIntPair<uint64_t *, 1, bool> VTableLayoutData;
- typedef llvm::DenseMap<const CXXRecordDecl *, VTableLayoutData>
- VTableLayoutMapTy;
+ // The layout entry.
+ typedef llvm::DenseMap<const CXXRecordDecl *, uint64_t *> VTableLayoutMapTy;
/// VTableLayoutMap - Stores the vtable layout for all record decls.
/// The layout is stored as an array of 64-bit integers, where the first
@@ -122,13 +119,13 @@ class CodeGenVTables {
uint64_t getNumVTableComponents(const CXXRecordDecl *RD) const {
assert(VTableLayoutMap.count(RD) && "No vtable layout for this class!");
- return VTableLayoutMap.lookup(RD).getPointer()[0];
+ return VTableLayoutMap.lookup(RD)[0];
}
const uint64_t *getVTableComponentsData(const CXXRecordDecl *RD) const {
assert(VTableLayoutMap.count(RD) && "No vtable layout for this class!");
- uint64_t *Components = VTableLayoutMap.lookup(RD).getPointer();
+ uint64_t *Components = VTableLayoutMap.lookup(RD);
return &Components[1];
}
@@ -157,8 +154,7 @@ class CodeGenVTables {
/// ComputeVTableRelatedInformation - Compute and store all vtable related
/// information (vtable layout, vbase offset offsets, thunks etc) for the
/// given record decl.
- void ComputeVTableRelatedInformation(const CXXRecordDecl *RD,
- bool VTableRequired);
+ void ComputeVTableRelatedInformation(const CXXRecordDecl *RD);
/// CreateVTableInitializer - Create a vtable initializer for the given record
/// decl.
OpenPOWER on IntegriCloud