mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Use a MapVector instead of an extra sort.
This also has the advantage of not depending on the brittle getLabelBeginName. llvm-svn: 231714
This commit is contained in:
parent
91da68b7ad
commit
bc2dad2e08
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user