diff options
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 31 | ||||
-rw-r--r-- | test/DebugInfo/X86/dwarf-aranges.ll | 18 |
2 files changed, 17 insertions, 32 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 04dedbd3f65..a4e5b8d3aab 100644 --- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -287,13 +287,6 @@ static StringRef getObjCMethodName(StringRef In) { return In.slice(In.find(' ') + 1, In.find(']')); } -// Helper for sorting sections into a stable output order. -static bool SectionSort(const MCSection *A, const MCSection *B) { - std::string LA = (A ? A->getLabelBeginName() : ""); - std::string LB = (B ? B->getLabelBeginName() : ""); - return LA < LB; -} - // Add the various names to the Dwarf accelerator table names. // TODO: Determine whether or not we should add names for programs // that do not have a DW_AT_name or DW_AT_linkage_name field - this @@ -1739,7 +1732,7 @@ struct ArangeSpan { // address we can tie back to a CU. void DwarfDebug::emitDebugARanges() { // Provides a unique id per text section. - DenseMap<const MCSection *, SmallVector<SymbolCU, 8>> SectionMap; + MapVector<const MCSection *, SmallVector<SymbolCU, 8>> SectionMap; // Filter labels by section. for (const SymbolCU &SCU : ArangeLabels) { @@ -1756,20 +1749,10 @@ void DwarfDebug::emitDebugARanges() { } } - // Build a list of sections used. - std::vector<const MCSection *> Sections; - for (const auto &it : SectionMap) { - const MCSection *Section = it.first; - Sections.push_back(Section); - } - - // Sort the sections into order. - // This is only done to ensure consistent output order across different runs. - std::sort(Sections.begin(), Sections.end(), SectionSort); - // Add terminating symbols for each section. - for (unsigned ID = 0, E = Sections.size(); ID != E; ID++) { - const MCSection *Section = Sections[ID]; + unsigned ID = 0; + for (const auto &I : SectionMap) { + const MCSection *Section = I.first; MCSymbol *Sym = nullptr; if (Section) { @@ -1784,12 +1767,14 @@ void DwarfDebug::emitDebugARanges() { // Insert a final terminator. SectionMap[Section].push_back(SymbolCU(nullptr, Sym)); + ++ID; } DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> Spans; - for (const MCSection *Section : Sections) { - SmallVector<SymbolCU, 8> &List = SectionMap[Section]; + for (auto &I : SectionMap) { + const MCSection *Section = I.first; + SmallVector<SymbolCU, 8> &List = I.second; if (List.size() < 2) continue; diff --git a/test/DebugInfo/X86/dwarf-aranges.ll b/test/DebugInfo/X86/dwarf-aranges.ll index b7e99302cd4..57207c4717e 100644 --- a/test/DebugInfo/X86/dwarf-aranges.ll +++ b/test/DebugInfo/X86/dwarf-aranges.ll @@ -9,21 +9,21 @@ ; -- alignment -- ; CHECK-NEXT: .zero 4,255 +; <data section> - it should have made one span covering all vars in this CU. +; CHECK-NEXT: .quad some_data +; CHECK-NEXT: .quad .Ldebug_end0-some_data + +; <other sections> - it should have made one span covering all vars in this CU. +; CHECK-NEXT: .quad some_other +; CHECK-NEXT: .quad .Ldebug_end1-some_other + ; <common symbols> - it should have made one span for each symbol. ; CHECK-NEXT: .quad some_bss ; CHECK-NEXT: .quad 4 -; <data section> - it should have made one span covering all vars in this CU. -; CHECK-NEXT: .quad some_data -; CHECK-NEXT: .quad .Ldebug_end1-some_data - ; <text section> - it should have made one span covering all functions in this CU. ; CHECK-NEXT: .quad .Lfunc_begin0 -; CHECK-NEXT: .quad .Ldebug_end2-.Lfunc_begin0 - -; <other sections> - it should have made one span covering all vars in this CU. -; CHECK-NEXT: .quad some_other -; CHECK-NEXT: .quad .Ldebug_end3-some_other +; CHECK-NEXT: .quad .Ldebug_end3-.Lfunc_begin0 ; -- finish -- ; CHECK-NEXT: # ARange terminator |