[llvm] r270165 - Fix pr27728.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 17:38:29 PDT 2016
Author: rafael
Date: Thu May 19 19:38:28 2016
New Revision: 270165
URL: http://llvm.org/viewvc/llvm-project?rev=270165&view=rev
Log:
Fix pr27728.
Sorry for the lack testcase. There is one in the pr, but it depends on
std::sort and the .ll version is 110 lines, so I don't think it is
wort it.
The bug was that we were sorting after adding a terminator, and the
sorting algorithm could end up putting the terminator in the middle of
the List vector.
With that we would create a Spans map entry keyed on nullptr which would
then be added to CUs and fail in that sorting.
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=270165&r1=270164&r2=270165&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Thu May 19 19:38:28 2016
@@ -1554,24 +1554,12 @@ void DwarfDebug::emitDebugARanges() {
}
}
- // Add terminating symbols for each section.
- for (const auto &I : SectionMap) {
- MCSection *Section = I.first;
- MCSymbol *Sym = nullptr;
-
- if (Section)
- Sym = Asm->OutStreamer->endSection(Section);
-
- // Insert a final terminator.
- SectionMap[Section].push_back(SymbolCU(nullptr, Sym));
- }
-
DenseMap<DwarfCompileUnit *, std::vector<ArangeSpan>> Spans;
for (auto &I : SectionMap) {
- const MCSection *Section = I.first;
+ MCSection *Section = I.first;
SmallVector<SymbolCU, 8> &List = I.second;
- if (List.size() < 2)
+ if (List.size() < 1)
continue;
// If we have no section (e.g. common), just write out
@@ -1581,8 +1569,8 @@ void DwarfDebug::emitDebugARanges() {
ArangeSpan Span;
Span.Start = Cur.Sym;
Span.End = nullptr;
- if (Cur.CU)
- Spans[Cur.CU].push_back(Span);
+ assert(Cur.CU);
+ Spans[Cur.CU].push_back(Span);
}
continue;
}
@@ -1602,6 +1590,9 @@ void DwarfDebug::emitDebugARanges() {
return IA < IB;
});
+ // Insert a final terminator.
+ List.push_back(SymbolCU(nullptr, Asm->OutStreamer->endSection(Section)));
+
// Build spans between each label.
const MCSymbol *StartSym = List[0].Sym;
for (size_t n = 1, e = List.size(); n < e; n++) {
@@ -1613,6 +1604,7 @@ void DwarfDebug::emitDebugARanges() {
ArangeSpan Span;
Span.Start = StartSym;
Span.End = Cur.Sym;
+ assert(Prev.CU);
Spans[Prev.CU].push_back(Span);
StartSym = Cur.Sym;
}
More information about the llvm-commits
mailing list