diff --git a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp --- a/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp @@ -406,9 +406,9 @@ DataExtractor D(IndexStr, DCtx.isLittleEndian(), 0); if (!Index.parse(D)) return 1; - IntervalMap::Allocator Alloc; - std::vector> Sections( - Index.getColumnKinds().size(), IntervalMap(Alloc)); + using MapType = IntervalMap; + MapType::Allocator Alloc; + std::vector> Sections(Index.getColumnKinds().size()); for (const DWARFUnitIndex::Entry &E : Index.getRows()) { uint64_t Sig = E.getSignature(); if (!E.getContributions()) @@ -421,16 +421,18 @@ int Col = E.index(); if (SC.Length == 0) continue; + if (!Sections[Col]) + Sections[Col] = std::make_unique(Alloc); auto &M = Sections[Col]; - auto I = M.find(SC.Offset); - if (I != M.end() && I.start() < (SC.Offset + SC.Length)) { + auto I = M->find(SC.Offset); + if (I != M->end() && I.start() < (SC.Offset + SC.Length)) { error() << llvm::formatv( "overlapping index entries for entries {0:x16} " "and {1:x16} for column {2}\n", *I, Sig, toString(Index.getColumnKinds()[Col])); return 1; } - M.insert(SC.Offset, SC.Offset + SC.Length - 1, Sig); + M->insert(SC.Offset, SC.Offset + SC.Length - 1, Sig); } }