mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-11 11:34:02 +00:00
Use a MapVector instead of an extra sort.
This also has the advantage of not depending on the brittle getLabelBeginName. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231714 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e8cbce94fd
commit
9e065f52fc
@ -287,13 +287,6 @@ static StringRef getObjCMethodName(StringRef In) {
|
|||||||
return In.slice(In.find(' ') + 1, In.find(']'));
|
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.
|
// Add the various names to the Dwarf accelerator table names.
|
||||||
// TODO: Determine whether or not we should add names for programs
|
// 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
|
// 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.
|
// address we can tie back to a CU.
|
||||||
void DwarfDebug::emitDebugARanges() {
|
void DwarfDebug::emitDebugARanges() {
|
||||||
// Provides a unique id per text section.
|
// 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.
|
// Filter labels by section.
|
||||||
for (const SymbolCU &SCU : ArangeLabels) {
|
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.
|
// Add terminating symbols for each section.
|
||||||
for (unsigned ID = 0, E = Sections.size(); ID != E; ID++) {
|
unsigned ID = 0;
|
||||||
const MCSection *Section = Sections[ID];
|
for (const auto &I : SectionMap) {
|
||||||
|
const MCSection *Section = I.first;
|
||||||
MCSymbol *Sym = nullptr;
|
MCSymbol *Sym = nullptr;
|
||||||
|
|
||||||
if (Section) {
|
if (Section) {
|
||||||
@ -1784,12 +1767,14 @@ void DwarfDebug::emitDebugARanges() {
|
|||||||
|
|
||||||
// Insert a final terminator.
|
// Insert a final terminator.
|
||||||
SectionMap[Section].push_back(SymbolCU(nullptr, Sym));
|
SectionMap[Section].push_back(SymbolCU(nullptr, Sym));
|
||||||
|
++ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> Spans;
|
DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> Spans;
|
||||||
|
|
||||||
for (const MCSection *Section : Sections) {
|
for (auto &I : SectionMap) {
|
||||||
SmallVector<SymbolCU, 8> &List = SectionMap[Section];
|
const MCSection *Section = I.first;
|
||||||
|
SmallVector<SymbolCU, 8> &List = I.second;
|
||||||
if (List.size() < 2)
|
if (List.size() < 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -9,21 +9,21 @@
|
|||||||
; -- alignment --
|
; -- alignment --
|
||||||
; CHECK-NEXT: .zero 4,255
|
; 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.
|
; <common symbols> - it should have made one span for each symbol.
|
||||||
; CHECK-NEXT: .quad some_bss
|
; CHECK-NEXT: .quad some_bss
|
||||||
; CHECK-NEXT: .quad 4
|
; 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.
|
; <text section> - it should have made one span covering all functions in this CU.
|
||||||
; CHECK-NEXT: .quad .Lfunc_begin0
|
; CHECK-NEXT: .quad .Lfunc_begin0
|
||||||
; CHECK-NEXT: .quad .Ldebug_end2-.Lfunc_begin0
|
; CHECK-NEXT: .quad .Ldebug_end3-.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
|
|
||||||
|
|
||||||
; -- finish --
|
; -- finish --
|
||||||
; CHECK-NEXT: # ARange terminator
|
; CHECK-NEXT: # ARange terminator
|
||||||
|
Loading…
x
Reference in New Issue
Block a user