DebugInfo: Move loclist base address from DwarfFile to DebugLocStream
There's no need to have more than one of these (there can be two
DwarfFiles - one for the .o, one for the .dwo - but only one loc/loclist
section (either in the .o or the .dwo) & certainly one per
DebugLocStream, which is currently singular in DwarfDebug)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375183 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/AsmPrinter/DebugLocStream.h b/lib/CodeGen/AsmPrinter/DebugLocStream.h
index 4ee277a..0db86b0 100644
--- a/lib/CodeGen/AsmPrinter/DebugLocStream.h
+++ b/lib/CodeGen/AsmPrinter/DebugLocStream.h
@@ -49,6 +49,7 @@
SmallVector<Entry, 32> Entries;
SmallString<256> DWARFBytes;
std::vector<std::string> Comments;
+ MCSymbol *Sym;
/// Only verbose textual output needs comments. This will be set to
/// true for that case, and false otherwise.
@@ -59,6 +60,12 @@
size_t getNumLists() const { return Lists.size(); }
const List &getList(size_t LI) const { return Lists[LI]; }
ArrayRef<List> getLists() const { return Lists; }
+ MCSymbol *getSym() const {
+ return Sym;
+ }
+ void setSym(MCSymbol *Sym) {
+ this->Sym = Sym;
+ }
class ListBuilder;
class EntryBuilder;
diff --git a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index e1b1932..c505e77 100644
--- a/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -965,8 +965,6 @@
DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder;
Holder.setRnglistsTableBaseSym(
Asm->createTempSymbol("rnglists_table_base"));
- Holder.setLoclistsTableBaseSym(
- Asm->createTempSymbol("loclists_table_base"));
if (useSplitDwarf())
InfoHolder.setRnglistsTableBaseSym(
@@ -1138,8 +1136,12 @@
if (U.hasRangeLists())
U.addRnglistsBase();
- if (!DebugLocs.getLists().empty() && !useSplitDwarf())
- U.addLoclistsBase();
+ if (!DebugLocs.getLists().empty() && !useSplitDwarf()) {
+ DebugLocs.setSym(Asm->createTempSymbol("loclists_table_base"));
+ U.addSectionLabel(U.getUnitDie(), dwarf::DW_AT_loclists_base,
+ DebugLocs.getSym(),
+ TLOF.getDwarfLoclistsSection()->getBeginSymbol());
+ }
}
auto *CUNode = cast<DICompileUnit>(P.first);
@@ -2304,16 +2306,18 @@
// designates the end of the table for the caller to emit when the table is
// complete.
static MCSymbol *emitLoclistsTableHeader(AsmPrinter *Asm,
- const DwarfFile &Holder) {
+ const DwarfDebug &DD) {
MCSymbol *TableStart = Asm->createTempSymbol("debug_loclist_table_start");
MCSymbol *TableEnd = Asm->createTempSymbol("debug_loclist_table_end");
emitListsTableHeaderStart(Asm, TableStart, TableEnd);
+ const auto &DebugLocs = DD.getDebugLocs();
+
// FIXME: Generate the offsets table and use DW_FORM_loclistx with the
// DW_AT_loclists_base attribute. Until then set the number of offsets to 0.
Asm->OutStreamer->AddComment("Offset entry count");
Asm->emitInt32(0);
- Asm->OutStreamer->EmitLabel(Holder.getLoclistsTableBaseSym());
+ Asm->OutStreamer->EmitLabel(DebugLocs.getSym());
return TableEnd;
}
@@ -2435,8 +2439,7 @@
if (getDwarfVersion() >= 5) {
Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getDwarfLoclistsSection());
- TableEnd = emitLoclistsTableHeader(Asm, useSplitDwarf() ? SkeletonHolder
- : InfoHolder);
+ TableEnd = emitLoclistsTableHeader(Asm, *this);
} else {
Asm->OutStreamer->SwitchSection(
Asm->getObjFileLowering().getDwarfLocSection());
diff --git a/lib/CodeGen/AsmPrinter/DwarfFile.h b/lib/CodeGen/AsmPrinter/DwarfFile.h
index 25ed8da..35fa51f 100644
--- a/lib/CodeGen/AsmPrinter/DwarfFile.h
+++ b/lib/CodeGen/AsmPrinter/DwarfFile.h
@@ -80,10 +80,6 @@
/// The table is shared by all units.
MCSymbol *RnglistsTableBaseSym = nullptr;
- /// DWARF v5: The symbol that designates the base of the locations list table.
- /// The table is shared by all units.
- MCSymbol *LoclistsTableBaseSym = nullptr;
-
/// The variables of a lexical scope.
struct ScopeVars {
/// We need to sort Args by ArgNo and check for duplicates. This could also
@@ -161,9 +157,6 @@
MCSymbol *getRnglistsTableBaseSym() const { return RnglistsTableBaseSym; }
void setRnglistsTableBaseSym(MCSymbol *Sym) { RnglistsTableBaseSym = Sym; }
- MCSymbol *getLoclistsTableBaseSym() const { return LoclistsTableBaseSym; }
- void setLoclistsTableBaseSym(MCSymbol *Sym) { LoclistsTableBaseSym = Sym; }
-
/// \returns false if the variable was merged with a previous one.
bool addScopeVariable(LexicalScope *LS, DbgVariable *Var);
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index ae11dc8..37c68c0 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1714,15 +1714,6 @@
TLOF.getDwarfRnglistsSection()->getBeginSymbol());
}
-void DwarfUnit::addLoclistsBase() {
- assert(DD->getDwarfVersion() >= 5 &&
- "DW_AT_loclists_base requires DWARF version 5 or later");
- const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
- addSectionLabel(getUnitDie(), dwarf::DW_AT_loclists_base,
- DU->getLoclistsTableBaseSym(),
- TLOF.getDwarfLoclistsSection()->getBeginSymbol());
-}
-
void DwarfTypeUnit::finishNonUnitTypeDIE(DIE& D, const DICompositeType *CTy) {
addFlag(D, dwarf::DW_AT_declaration);
StringRef Name = CTy->getName();
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.h b/lib/CodeGen/AsmPrinter/DwarfUnit.h
index a188002..46c52a1 100644
--- a/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -272,9 +272,6 @@
/// Add the DW_AT_rnglists_base attribute to the unit DIE.
void addRnglistsBase();
- /// Add the DW_AT_loclists_base attribute to the unit DIE.
- void addLoclistsBase();
-
virtual DwarfCompileUnit &getCU() = 0;
void constructTypeDIE(DIE &Buffer, const DICompositeType *CTy);