From 0487c74613ee4040593af19c75dfb7910f5b3bfb Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 26 Nov 2013 00:15:27 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195696 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 51 +++++---------------- lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 8 +--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 3 -- 3 files changed, 13 insertions(+), 49 deletions(-) diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 73d0a839a7b..abb550e0d1d 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -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. diff --git a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index 0821a9a2b98..8fdd2e012d1 100644 --- a/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -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 diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 90f370ccf71..e1ffa05412f 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -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; } -- 2.34.1