diff options
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h index bacf87d95c4..b47cbae5b22 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -15,6 +15,7 @@ #define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFCOMPILEUNIT_H #include "DwarfUnit.h" +#include "llvm/ADT/SetVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/DebugInfo.h" #include "llvm/Support/Dwarf.h" @@ -48,11 +49,10 @@ class DwarfCompileUnit : public DwarfUnit { /// The start of the unit macro info within macro section. MCSymbol *MacroLabelBegin; - typedef llvm::SmallVector<const MDNode *, 8> ImportedEntityList; - typedef llvm::DenseMap<const MDNode *, ImportedEntityList> - ImportedEntityMap; + typedef llvm::SmallVector<const MDNode *, 8> LocalDeclNodeList; + typedef llvm::DenseMap<const MDNode *, LocalDeclNodeList> LocalScopesMap; - ImportedEntityMap ImportedEntities; + LocalScopesMap LocalDeclNodes; /// GlobalNames - A map of globally visible named entities for this unit. StringMap<const DIE *> GlobalNames; @@ -71,6 +71,15 @@ class DwarfCompileUnit : public DwarfUnit { // ranges/locs. const MCSymbol *BaseAddress; + struct LocalScopeDieInfo { + DIE *ConcreteLSDie = nullptr; + DIE *AbstractLSDie = nullptr; + SetVector<DIE *> InlineLSDies; + SetVector<DIE *> LocalDclDies; + }; + // Collection of local scope DIE info. + DenseMap<const MDNode *, LocalScopeDieInfo> LocalScopeDieInfoMap; + /// \brief Construct a DIE for the given DbgVariable without initializing the /// DbgVariable's DIE reference. DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract); @@ -117,8 +126,16 @@ public: unsigned getOrCreateSourceID(StringRef FileName, StringRef DirName) override; - void addImportedEntity(const DIImportedEntity* IE) { - ImportedEntities[IE->getScope()].push_back(IE); + void addLocalDeclNode(const DINode *DI, DILocalScope *Scope) { + // LocalDeclNodes maps local declaration DIEs to their parent DILocalScope. + // These local declaration entities will be processed when processing the + // lexical scopes collected by LexicalScopes component. + // DILexicalBlockFile is skipped by LexicalScopes and it collect its parent, + // which is of a DILexicalBlock. Thus, LocalDeclNodes must not map to + // DILexicalBlockFile but to its parent DILexicalBlock. + if (auto *File = dyn_cast<DILexicalBlockFile>(Scope)) + Scope = File->getScope(); + LocalDeclNodes[Scope].push_back(DI); } /// addRange - Add an address range to the list of ranges for this unit. @@ -166,7 +183,7 @@ public: /// A helper function to create children of a Scope DIE. DIE *createScopeChildrenDIE(LexicalScope *Scope, SmallVectorImpl<DIE *> &Children, - unsigned *ChildScopeCount = nullptr); + bool *HasNonScopeChildren = nullptr); /// \brief Construct a DIE for this subprogram scope. void constructSubprogramScopeDIE(LexicalScope *Scope); @@ -175,11 +192,15 @@ public: void constructAbstractSubprogramScopeDIE(LexicalScope *Scope); + /// \brief Get or create import_module DIE. + DIE *getOrCreateImportedEntityDIE(const DIImportedEntity *Module); /// \brief Construct import_module DIE. DIE *constructImportedEntityDIE(const DIImportedEntity *Module); void finishSubprogramDefinition(const DISubprogram *SP); + void finishLocalScopeDefinitions(); + void collectDeadVariables(const DISubprogram *SP); /// Set the skeleton unit associated with this unit. @@ -253,6 +274,15 @@ public: void setBaseAddress(const MCSymbol *Base) { BaseAddress = Base; } const MCSymbol *getBaseAddress() const { return BaseAddress; } + + DenseMap<const MDNode *, LocalScopeDieInfo> &getLSDieInfoMap() { + return LocalScopeDieInfoMap; + } + + /// Add local scope DIE entry to lexical scope info. + void addLocalScopeDieToLexicalScope(LexicalScope *LS, DIE *D); + /// Add local declaration DIE entry to lexical scope info. + void addLocalDclDieToLexicalScope(LexicalScope *LS, DIE *D); }; } // end llvm namespace |