NFC: DebugInfo: Track the origin CU rather than just the base address for range lists
Turns out knowing more than just the base address might be useful -
specifically a future change to respect a DICompileUnit flag for the use
of base address specifiers in DWARF < 5.
llvm-svn: 346380
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index a32cd8b..d93c7f6 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -430,8 +430,7 @@
// Add the range list to the set of ranges to be emitted.
auto IndexAndList =
(DD->getDwarfVersion() < 5 && Skeleton ? Skeleton->DU : DU)
- ->addRange((Skeleton ? Skeleton->BaseAddress : BaseAddress),
- std::move(Range));
+ ->addRange(*(Skeleton ? Skeleton : this), std::move(Range));
uint32_t Index = IndexAndList.first;
auto &List = *IndexAndList.second;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 2807734..070b8fe 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2275,7 +2275,8 @@
for (const RangeSpan &Range : List.getRanges())
SectionRanges[&Range.getStart()->getSection()].push_back(&Range);
- const MCSymbol *CUBase = List.getBaseAddress();
+ const DwarfCompileUnit &CU = List.getCU();
+ const MCSymbol *CUBase = CU.getBaseAddress();
bool BaseIsSet = false;
for (const auto &P : SectionRanges) {
// Don't bother with a base address entry if there's only one range in
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
index 1e5b7f1..4e410bb 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp
@@ -111,9 +111,8 @@
}
std::pair<uint32_t, RangeSpanList *>
-DwarfFile::addRange(const MCSymbol *&CUBaseAddress,
- SmallVector<RangeSpan, 2> R) {
- CURangeLists.push_back(RangeSpanList(Asm->createTempSymbol("debug_ranges"),
- CUBaseAddress, std::move(R)));
+DwarfFile::addRange(const DwarfCompileUnit &CU, SmallVector<RangeSpan, 2> R) {
+ CURangeLists.push_back(
+ RangeSpanList(Asm->createTempSymbol("debug_ranges"), CU, std::move(R)));
return std::make_pair(CURangeLists.size() - 1, &CURangeLists.back());
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
index 1e5c99e..51acca8 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfFile.h
@@ -48,17 +48,16 @@
private:
// Index for locating within the debug_range section this particular span.
MCSymbol *RangeSym;
- const MCSymbol **CUBaseAddress;
+ const DwarfCompileUnit *CU;
// List of ranges.
SmallVector<RangeSpan, 2> Ranges;
public:
- RangeSpanList(MCSymbol *Sym, const MCSymbol *&CUBaseAddress,
+ RangeSpanList(MCSymbol *Sym, const DwarfCompileUnit &CU,
SmallVector<RangeSpan, 2> Ranges)
- : RangeSym(Sym), CUBaseAddress(&CUBaseAddress),
- Ranges(std::move(Ranges)) {}
+ : RangeSym(Sym), CU(&CU), Ranges(std::move(Ranges)) {}
MCSymbol *getSym() const { return RangeSym; }
- const MCSymbol *&getBaseAddress() const { return *CUBaseAddress; }
+ const DwarfCompileUnit &getCU() const { return *CU; }
const SmallVectorImpl<RangeSpan> &getRanges() const { return Ranges; }
void addRange(RangeSpan Range) { Ranges.push_back(Range); }
};
@@ -123,7 +122,7 @@
return CUs;
}
- std::pair<uint32_t, RangeSpanList *> addRange(const MCSymbol *&CUBaseAddress,
+ std::pair<uint32_t, RangeSpanList *> addRange(const DwarfCompileUnit &CU,
SmallVector<RangeSpan, 2> R);
/// getRangeLists - Get the vector of range lists.