DebugInfo: Pubtypes: Coelesce pubtype registration with accelerator type registration.

It might be possible to eventually use one data structure, but I haven't
looked at the exact criteria used for accelerator tables and pubtypes to
see if there's good reason for the differences between the two or not.

llvm-svn: 195696
This commit is contained in:
David Blaikie 2013-11-26 00:15:27 +00:00
parent 4184a471f2
commit 9d861bed9b
3 changed files with 13 additions and 49 deletions

View File

@ -913,7 +913,8 @@ DIE *CompileUnit::getOrCreateContextDIE(DIScope Context) {
}
DIE *CompileUnit::createTypeDIE(DICompositeType Ty) {
DIE *ContextDIE = getOrCreateContextDIE(resolve(Ty.getContext()));
DIScope Context = resolve(Ty.getContext());
DIE *ContextDIE = getOrCreateContextDIE(Context);
DIE *TyDIE = getDIE(Ty);
if (TyDIE)
@ -924,7 +925,7 @@ DIE *CompileUnit::createTypeDIE(DICompositeType Ty) {
constructTypeDIEImpl(*TyDIE, Ty);
updateAcceleratorTables(Ty, TyDIE);
updateAcceleratorTables(Context, Ty, TyDIE);
return TyDIE;
}
@ -939,7 +940,8 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
// Construct the context before querying for the existence of the DIE in case
// such construction creates the DIE.
DIE *ContextDIE = getOrCreateContextDIE(resolve(Ty.getContext()));
DIScope Context = resolve(Ty.getContext());
DIE *ContextDIE = getOrCreateContextDIE(Context);
assert(ContextDIE);
DIE *TyDIE = getDIE(Ty);
@ -958,12 +960,13 @@ DIE *CompileUnit::getOrCreateTypeDIE(const MDNode *TyNode) {
constructTypeDIE(*TyDIE, DIDerivedType(Ty));
}
updateAcceleratorTables(Ty, TyDIE);
updateAcceleratorTables(Context, Ty, TyDIE);
return TyDIE;
}
void CompileUnit::updateAcceleratorTables(DIType Ty, const DIE *TyDIE) {
void CompileUnit::updateAcceleratorTables(DIScope Context, DIType Ty,
const DIE *TyDIE) {
if (!Ty.getName().empty() && !Ty.isForwardDecl()) {
bool IsImplementation = 0;
if (Ty.isCompositeType()) {
@ -974,6 +977,10 @@ void CompileUnit::updateAcceleratorTables(DIType Ty, const DIE *TyDIE) {
}
unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0;
addAccelType(Ty.getName(), std::make_pair(TyDIE, Flags));
if (!Context || Context.isCompileUnit() || Context.isFile() ||
Context.isNameSpace())
GlobalTypes[getParentContextString(Context) + Ty.getName().str()] = TyDIE;
}
}
@ -996,10 +1003,6 @@ void CompileUnit::addType(DIE *Entity, DIType Ty, dwarf::Attribute Attribute) {
Entry = createDIEEntry(Buffer);
insertDIEEntry(Ty, Entry);
addDIEEntry(Entity, Attribute, Entry);
// If this is a complete composite type then include it in the
// list of global types.
addGlobalType(Ty);
}
// Accelerator table mutators - add each name along with its companion
@ -1037,20 +1040,6 @@ void CompileUnit::addGlobalName(StringRef Name, DIE *Die, DIScope Context) {
GlobalNames[FullName] = Die;
}
/// addGlobalType - Add a new global type to the compile unit.
///
void CompileUnit::addGlobalType(DIType Ty) {
DIScope Context = resolve(Ty.getContext());
if (!Ty.getName().empty() && !Ty.isForwardDecl() &&
(!Context || Context.isCompileUnit() || Context.isFile() ||
Context.isNameSpace()))
if (DIEEntry *Entry = getDIEEntry(Ty)) {
std::string FullName =
getParentContextString(Context) + Ty.getName().str();
GlobalTypes[FullName] = Entry->getEntry();
}
}
/// getParentContextString - Walks the metadata parent chain in a language
/// specific manner (using the compile unit language) and returns
/// it as a string. This is done at the metadata level because DIEs may
@ -1091,22 +1080,6 @@ std::string CompileUnit::getParentContextString(DIScope Context) const {
return CS;
}
/// addPubTypes - Add subprogram argument types for pubtypes section.
void CompileUnit::addPubTypes(DISubprogram SP) {
DICompositeType SPTy = SP.getType();
uint16_t SPTag = SPTy.getTag();
if (SPTag != dwarf::DW_TAG_subroutine_type)
return;
DIArray Args = SPTy.getTypeArray();
for (unsigned i = 0, e = Args.getNumElements(); i != e; ++i) {
DIType ATy(Args.getElement(i));
if (!ATy.isType())
continue;
addGlobalType(ATy);
}
}
/// constructTypeDIE - Construct basic type die from DIBasicType.
void CompileUnit::constructTypeDIE(DIE &Buffer, DIBasicType BTy) {
// Get core information.

View File

@ -143,12 +143,6 @@ public:
///
void addGlobalName(StringRef Name, DIE *Die, DIScope Context);
/// addGlobalType - Add a new global type to the compile unit.
void addGlobalType(DIType Ty);
/// addPubTypes - Add a set of types from the subprogram to the global types.
void addPubTypes(DISubprogram SP);
/// addAccelName - Add a new name to the name accelerator table.
void addAccelName(StringRef Name, const DIE *Die);
@ -417,7 +411,7 @@ private:
/// 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);
void updateAcceleratorTables(DIScope Context, DIType Ty, const DIE *TyDIE);
};
} // end llvm namespace

View File

@ -685,9 +685,6 @@ DIE *DwarfDebug::constructScopeDIE(CompileUnit *TheCU, LexicalScope *Scope) {
if (DS.isSubprogram() && ObjectPointer != NULL)
TheCU->addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, ObjectPointer);
if (DS.isSubprogram())
TheCU->addPubTypes(DISubprogram(DS));
return ScopeDIE;
}