Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.h =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.h @@ -87,6 +87,10 @@ /// DbgVariable's DIE reference. DIE *constructVariableDIEImpl(const DbgVariable &DV, bool Abstract); + /// \brief Construct a DIE for the given DbgLabel without initializing the + /// DbgLabel's DIE reference. + DIE *constructLabelDIEImpl(const DbgLabel &DL); + bool isDwoUnit() const override; DenseMap &getAbstractSPDies() { @@ -191,6 +195,9 @@ DIE *constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope, DIE *&ObjectPointer); + /// constructLabelDIE - Construct a DIE for the given DbgLabel. + DIE *constructLabelDIE(DbgLabel &DL); + /// A helper function to create children of a Scope DIE. DIE *createScopeChildrenDIE(LexicalScope *Scope, SmallVectorImpl &Children, Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -487,6 +487,13 @@ return D; } +/// constructLabelDIE - Construct a DIE for the given DbgLabel. +DIE *DwarfCompileUnit::constructLabelDIE(DbgLabel &DL) { + auto D = constructLabelDIEImpl(DL); + DL.setDIE(*D); + return D; +} + DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV, bool Abstract) { // Define variable debug information entry. @@ -566,6 +573,12 @@ return VariableDie; } +DIE *DwarfCompileUnit::constructLabelDIEImpl(const DbgLabel &DL) { + // Define label debug information entry. + auto LabelDie = DIE::get(DIEValueAllocator, DL.getTag()); + return LabelDie; +} + DIE *DwarfCompileUnit::constructVariableDIE(DbgVariable &DV, const LexicalScope &Scope, DIE *&ObjectPointer) { @@ -677,6 +690,9 @@ if (HasNonScopeChildren) *HasNonScopeChildren = !Children.empty(); + for (DbgLabel *DL : DU->getScopeLabels().lookup(Scope)) + Children.push_back(constructLabelDIE(*DL)); + for (LexicalScope *LS : Scope->getChildren()) constructScopeDIE(LS, Children);