mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
DebugInfo: Constify accelerator table handling, and separate type accelarator insertion in preparation for a second use of this code from type units.
llvm-svn: 195164
This commit is contained in:
parent
242935ec8c
commit
395dc41d93
@ -31,7 +31,7 @@ DwarfAccelTable::DwarfAccelTable(ArrayRef<DwarfAccelTable::Atom> atomList)
|
||||
|
||||
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.
|
||||
|
@ -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
|
||||
|
@ -900,8 +900,13 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
|
||||
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(const MDNode *TyNode) {
|
||||
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, DIType Ty, dwarf::Attribute Attribute) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user