diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp --- a/bolt/lib/Core/DebugData.cpp +++ b/bolt/lib/Core/DebugData.cpp @@ -1298,8 +1298,11 @@ // FIXME: if we had a full access to DWARFDebugAbbrev::AbbrDeclSets // we wouldn't have to build our own sorted list for the quick lookup. if (AbbrevSetOffsets.empty()) { + const DWARFDebugAbbrev *DebugAbbrev = + Unit.getContext().getDebugAbbrev(); + DebugAbbrev->parse(); for (const std::pair - &P : *Unit.getContext().getDebugAbbrev()) + &P : *DebugAbbrev) AbbrevSetOffsets.push_back(P.first); sort(AbbrevSetOffsets); } diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h --- a/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h +++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h @@ -73,7 +73,7 @@ void parse() const; DWARFAbbreviationDeclarationSetMap::const_iterator begin() const { - parse(); + assert(!Data && "Must call parse before iterating over DWARFDebugAbbrev"); return AbbrDeclSets.begin(); } diff --git a/llvm/tools/obj2yaml/dwarf2yaml.cpp b/llvm/tools/obj2yaml/dwarf2yaml.cpp --- a/llvm/tools/obj2yaml/dwarf2yaml.cpp +++ b/llvm/tools/obj2yaml/dwarf2yaml.cpp @@ -26,6 +26,7 @@ auto AbbrevSetPtr = DCtx.getDebugAbbrev(); if (AbbrevSetPtr) { uint64_t AbbrevTableID = 0; + AbbrevSetPtr->parse(); for (auto AbbrvDeclSet : *AbbrevSetPtr) { Y.DebugAbbrev.emplace_back(); Y.DebugAbbrev.back().ID = AbbrevTableID++; @@ -219,6 +220,7 @@ if (NewUnit.Version >= 5) NewUnit.Type = (dwarf::UnitType)CU->getUnitType(); const DWARFDebugAbbrev *DebugAbbrev = DCtx.getDebugAbbrev(); + DebugAbbrev->parse(); NewUnit.AbbrevTableID = std::distance( DebugAbbrev->begin(), llvm::find_if(