[llvm] r195164 - DebugInfo: Constify accelerator table handling, and separate type accelarator insertion in preparation for a second use of this code from type units.
David Blaikie
dblaikie at gmail.com
Tue Nov 19 14:51:04 PST 2013
Author: dblaikie
Date: Tue Nov 19 16:51:04 2013
New Revision: 195164
URL: http://llvm.org/viewvc/llvm-project?rev=195164&view=rev
Log:
DebugInfo: Constify accelerator table handling, and separate type accelarator insertion in preparation for a second use of this code from type units.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp?rev=195164&r1=195163&r2=195164&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.cpp Tue Nov 19 16:51:04 2013
@@ -31,7 +31,7 @@ DwarfAccelTable::DwarfAccelTable(ArrayRe
DwarfAccelTable::~DwarfAccelTable() {}
-void DwarfAccelTable::AddName(StringRef Name, DIE *die, char Flags) {
+void DwarfAccelTable::AddName(StringRef Name, const DIE *die, char Flags) {
assert(Data.empty() && "Already finalized!");
// If the string is in the list already then add this die to the list
// otherwise add a new one.
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h?rev=195164&r1=195163&r2=195164&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfAccelTable.h Tue Nov 19 16:51:04 2013
@@ -165,10 +165,10 @@ private:
// HashData[hash_data_count]
public:
struct HashDataContents {
- DIE *Die; // Offsets
+ const DIE *Die; // Offsets
char Flags; // Specific flags to output
- HashDataContents(DIE *D, char Flags) : Die(D), Flags(Flags) {}
+ HashDataContents(const DIE *D, char Flags) : Die(D), Flags(Flags) {}
#ifndef NDEBUG
void print(raw_ostream &O) const {
O << " Offset: " << Die->getOffset() << "\n";
@@ -241,7 +241,7 @@ private:
public:
DwarfAccelTable(ArrayRef<DwarfAccelTable::Atom>);
~DwarfAccelTable();
- void AddName(StringRef, DIE *, char = 0);
+ void AddName(StringRef, const DIE *, char = 0);
void FinalizeTable(AsmPrinter *, StringRef);
void Emit(AsmPrinter *, MCSymbol *, DwarfUnits *);
#ifndef NDEBUG
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=195164&r1=195163&r2=195164&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Tue Nov 19 16:51:04 2013
@@ -900,8 +900,13 @@ DIE *CompileUnit::getOrCreateTypeDIE(con
assert(Ty.isDerivedType() && "Unknown kind of DIType");
constructTypeDIE(*TyDIE, DIDerivedType(Ty));
}
- // If this is a named finished type then include it in the list of types
- // for the accelerator tables.
+
+ updateAcceleratorTables(Ty, TyDIE);
+
+ return TyDIE;
+}
+
+void CompileUnit::updateAcceleratorTables(DIType Ty, const DIE *TyDIE) {
if (!Ty.getName().empty() && !Ty.isForwardDecl()) {
bool IsImplementation = 0;
if (Ty.isCompositeType()) {
@@ -913,8 +918,6 @@ DIE *CompileUnit::getOrCreateTypeDIE(con
unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0;
addAccelType(Ty.getName(), std::make_pair(TyDIE, Flags));
}
-
- return TyDIE;
}
/// addType - Add a new type attribute to the specified entity.
@@ -946,27 +949,28 @@ void CompileUnit::addType(DIE *Entity, D
// DIE to the proper table while ensuring that the name that we're going
// to reference is in the string table. We do this since the names we
// add may not only be identical to the names in the DIE.
-void CompileUnit::addAccelName(StringRef Name, DIE *Die) {
+void CompileUnit::addAccelName(StringRef Name, const DIE *Die) {
DU->getStringPoolEntry(Name);
- std::vector<DIE *> &DIEs = AccelNames[Name];
+ std::vector<const DIE *> &DIEs = AccelNames[Name];
DIEs.push_back(Die);
}
-void CompileUnit::addAccelObjC(StringRef Name, DIE *Die) {
+void CompileUnit::addAccelObjC(StringRef Name, const DIE *Die) {
DU->getStringPoolEntry(Name);
- std::vector<DIE *> &DIEs = AccelObjC[Name];
+ std::vector<const DIE *> &DIEs = AccelObjC[Name];
DIEs.push_back(Die);
}
-void CompileUnit::addAccelNamespace(StringRef Name, DIE *Die) {
+void CompileUnit::addAccelNamespace(StringRef Name, const DIE *Die) {
DU->getStringPoolEntry(Name);
- std::vector<DIE *> &DIEs = AccelNamespace[Name];
+ std::vector<const DIE *> &DIEs = AccelNamespace[Name];
DIEs.push_back(Die);
}
-void CompileUnit::addAccelType(StringRef Name, std::pair<DIE *, unsigned> Die) {
+void CompileUnit::addAccelType(StringRef Name,
+ std::pair<const DIE *, unsigned> Die) {
DU->getStringPoolEntry(Name);
- std::vector<std::pair<DIE *, unsigned> > &DIEs = AccelTypes[Name];
+ std::vector<std::pair<const DIE *, unsigned> > &DIEs = AccelTypes[Name];
DIEs.push_back(Die);
}
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=195164&r1=195163&r2=195164&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Tue Nov 19 16:51:04 2013
@@ -74,10 +74,10 @@ class CompileUnit {
/// AccelNames - A map of names for the name accelerator table.
///
- StringMap<std::vector<DIE *> > AccelNames;
- StringMap<std::vector<DIE *> > AccelObjC;
- StringMap<std::vector<DIE *> > AccelNamespace;
- StringMap<std::vector<std::pair<DIE *, unsigned> > > AccelTypes;
+ StringMap<std::vector<const DIE *> > AccelNames;
+ StringMap<std::vector<const DIE *> > AccelObjC;
+ StringMap<std::vector<const DIE *> > AccelNamespace;
+ StringMap<std::vector<std::pair<const DIE *, unsigned> > > AccelTypes;
/// DIEBlocks - A list of all the DIEBlocks in use.
std::vector<DIEBlock *> DIEBlocks;
@@ -106,16 +106,16 @@ public:
const StringMap<DIE *> &getGlobalNames() const { return GlobalNames; }
const StringMap<DIE *> &getGlobalTypes() const { return GlobalTypes; }
- const StringMap<std::vector<DIE *> > &getAccelNames() const {
+ const StringMap<std::vector<const DIE *> > &getAccelNames() const {
return AccelNames;
}
- const StringMap<std::vector<DIE *> > &getAccelObjC() const {
+ const StringMap<std::vector<const DIE *> > &getAccelObjC() const {
return AccelObjC;
}
- const StringMap<std::vector<DIE *> > &getAccelNamespace() const {
+ const StringMap<std::vector<const DIE *> > &getAccelNamespace() const {
return AccelNamespace;
}
- const StringMap<std::vector<std::pair<DIE *, unsigned> > > &
+ const StringMap<std::vector<std::pair<const DIE *, unsigned> > > &
getAccelTypes() const {
return AccelTypes;
}
@@ -143,16 +143,16 @@ public:
void addPubTypes(DISubprogram SP);
/// addAccelName - Add a new name to the name accelerator table.
- void addAccelName(StringRef Name, DIE *Die);
+ void addAccelName(StringRef Name, const DIE *Die);
/// addAccelObjC - Add a new name to the ObjC accelerator table.
- void addAccelObjC(StringRef Name, DIE *Die);
+ void addAccelObjC(StringRef Name, const DIE *Die);
/// addAccelNamespace - Add a new name to the namespace accelerator table.
- void addAccelNamespace(StringRef Name, DIE *Die);
+ void addAccelNamespace(StringRef Name, const DIE *Die);
/// addAccelType - Add a new type to the type accelerator table.
- void addAccelType(StringRef Name, std::pair<DIE *, unsigned> Die);
+ void addAccelType(StringRef Name, std::pair<const DIE *, unsigned> Die);
/// getDIE - Returns the debug information entry map slot for the
/// specified debug variable. We delegate the request to DwarfDebug
@@ -408,6 +408,10 @@ private:
template <typename T> T resolve(DIRef<T> Ref) const {
return DD->resolve(Ref);
}
+
+ /// If this is a named finished type then include it in the list of types for
+ /// the accelerator tables.
+ void updateAcceleratorTables(DIType Ty, const DIE *TyDIE);
};
} // end llvm namespace
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=195164&r1=195163&r2=195164&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Nov 19 16:51:04 2013
@@ -2247,16 +2247,17 @@ void DwarfDebug::emitAccelNames() {
E = CUMap.end();
I != E; ++I) {
CompileUnit *TheCU = I->second;
- const StringMap<std::vector<DIE *> > &Names = TheCU->getAccelNames();
- for (StringMap<std::vector<DIE *> >::const_iterator GI = Names.begin(),
- GE = Names.end();
+ const StringMap<std::vector<const DIE *> > &Names = TheCU->getAccelNames();
+ for (StringMap<std::vector<const DIE *> >::const_iterator
+ GI = Names.begin(),
+ GE = Names.end();
GI != GE; ++GI) {
StringRef Name = GI->getKey();
- const std::vector<DIE *> &Entities = GI->second;
- for (std::vector<DIE *>::const_iterator DI = Entities.begin(),
- DE = Entities.end();
+ const std::vector<const DIE *> &Entities = GI->second;
+ for (std::vector<const DIE *>::const_iterator DI = Entities.begin(),
+ DE = Entities.end();
DI != DE; ++DI)
- AT.AddName(Name, (*DI));
+ AT.AddName(Name, *DI);
}
}
@@ -2279,16 +2280,17 @@ void DwarfDebug::emitAccelObjC() {
E = CUMap.end();
I != E; ++I) {
CompileUnit *TheCU = I->second;
- const StringMap<std::vector<DIE *> > &Names = TheCU->getAccelObjC();
- for (StringMap<std::vector<DIE *> >::const_iterator GI = Names.begin(),
- GE = Names.end();
+ const StringMap<std::vector<const DIE *> > &Names = TheCU->getAccelObjC();
+ for (StringMap<std::vector<const DIE *> >::const_iterator
+ GI = Names.begin(),
+ GE = Names.end();
GI != GE; ++GI) {
StringRef Name = GI->getKey();
- const std::vector<DIE *> &Entities = GI->second;
- for (std::vector<DIE *>::const_iterator DI = Entities.begin(),
- DE = Entities.end();
+ const std::vector<const DIE *> &Entities = GI->second;
+ for (std::vector<const DIE *>::const_iterator DI = Entities.begin(),
+ DE = Entities.end();
DI != DE; ++DI)
- AT.AddName(Name, (*DI));
+ AT.AddName(Name, *DI);
}
}
@@ -2310,16 +2312,18 @@ void DwarfDebug::emitAccelNamespaces() {
E = CUMap.end();
I != E; ++I) {
CompileUnit *TheCU = I->second;
- const StringMap<std::vector<DIE *> > &Names = TheCU->getAccelNamespace();
- for (StringMap<std::vector<DIE *> >::const_iterator GI = Names.begin(),
- GE = Names.end();
+ const StringMap<std::vector<const DIE *> > &Names =
+ TheCU->getAccelNamespace();
+ for (StringMap<std::vector<const DIE *> >::const_iterator
+ GI = Names.begin(),
+ GE = Names.end();
GI != GE; ++GI) {
StringRef Name = GI->getKey();
- const std::vector<DIE *> &Entities = GI->second;
- for (std::vector<DIE *>::const_iterator DI = Entities.begin(),
- DE = Entities.end();
+ const std::vector<const DIE *> &Entities = GI->second;
+ for (std::vector<const DIE *>::const_iterator DI = Entities.begin(),
+ DE = Entities.end();
DI != DE; ++DI)
- AT.AddName(Name, (*DI));
+ AT.AddName(Name, *DI);
}
}
@@ -2347,19 +2351,21 @@ void DwarfDebug::emitAccelTypes() {
E = CUMap.end();
I != E; ++I) {
CompileUnit *TheCU = I->second;
- const StringMap<std::vector<std::pair<DIE *, unsigned> > > &Names =
+ const StringMap<std::vector<std::pair<const DIE *, unsigned> > > &Names =
TheCU->getAccelTypes();
- for (StringMap<std::vector<std::pair<DIE *, unsigned> > >::const_iterator
+ for (StringMap<
+ std::vector<std::pair<const DIE *, unsigned> > >::const_iterator
GI = Names.begin(),
GE = Names.end();
GI != GE; ++GI) {
StringRef Name = GI->getKey();
- const std::vector<std::pair<DIE *, unsigned> > &Entities = GI->second;
- for (std::vector<std::pair<DIE *, unsigned> >::const_iterator
+ const std::vector<std::pair<const DIE *, unsigned> > &Entities =
+ GI->second;
+ for (std::vector<std::pair<const DIE *, unsigned> >::const_iterator
DI = Entities.begin(),
DE = Entities.end();
DI != DE; ++DI)
- AT.AddName(Name, (*DI).first, (*DI).second);
+ AT.AddName(Name, DI->first, DI->second);
}
}
More information about the llvm-commits
mailing list