summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorPaul Robinson <paul.robinson@sony.com>2018-03-27 21:28:59 +0000
committerPaul Robinson <paul.robinson@sony.com>2018-03-27 21:28:59 +0000
commit7cb26ad2ef0714b010269d92eb5570f6a1b619df (patch)
tree0b8c5949be20c7b3a899e28bbfbf2c6d3af6a24a /llvm/lib
parent01bfd6c4e5c48d8f3997f12103735161e8bd09cc (diff)
downloadbcm5719-llvm-7cb26ad2ef0714b010269d92eb5570f6a1b619df.tar.gz
bcm5719-llvm-7cb26ad2ef0714b010269d92eb5570f6a1b619df.zip
[DWARF] Suppress split line tables more carefully.
If a given split type unit does not have source locations, don't have it refer to the split line table. If no split type unit refers to the split line table, don't emit the line table at all. This will save a little space on rare occasions, but also refactors things a bit to improve which class is responsible for what. Responding to review comments on r326395. Differential Revision: https://reviews.llvm.org/D44220 llvm-svn: 328670
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp10
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h4
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp17
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h1
-rw-r--r--llvm/lib/MC/MCDwarf.cpp7
5 files changed, 19 insertions, 20 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index b392586ef10..024472db87c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2122,11 +2122,9 @@ void DwarfDebug::emitDebugAbbrevDWO() {
void DwarfDebug::emitDebugLineDWO() {
assert(useSplitDwarf() && "No split dwarf?");
- if (!HasSplitTypeUnits)
- return;
- Asm->OutStreamer->SwitchSection(
+ SplitTypeUnitFileTable.Emit(
+ *Asm->OutStreamer, MCDwarfLineTableParams(),
Asm->getObjFileLowering().getDwarfLineDWOSection());
- SplitTypeUnitFileTable.Emit(*Asm->OutStreamer, MCDwarfLineTableParams());
}
void DwarfDebug::emitStringOffsetsTableHeaderDWO() {
@@ -2200,8 +2198,9 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
if (useSplitDwarf())
NewTU.setSection(Asm->getObjFileLowering().getDwarfTypesDWOSection());
else {
- CU.applyStmtList(UnitDie);
NewTU.setSection(Asm->getObjFileLowering().getDwarfTypesSection(Signature));
+ // Non-split type units reuse the compile unit's line table.
+ CU.applyStmtList(UnitDie);
}
// Add DW_AT_str_offsets_base to the type unit DIE, but not for split type
@@ -2239,7 +2238,6 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU,
InfoHolder.computeSizeAndOffsetsForUnit(TU.first.get());
InfoHolder.emitUnit(TU.first.get(), useSplitDwarf());
}
- HasSplitTypeUnits = useSplitDwarf();
}
CU.addDIETypeSignature(RefDie, Signature);
}
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
index 52b920682ce..3ee78710e8f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
@@ -280,10 +280,6 @@ class DwarfDebug : public DebugHandlerBase {
/// a monolithic sequence of string offsets.
bool UseSegmentedStringOffsetsTable;
- /// Whether we have emitted any type units with split DWARF (and therefore
- /// need to emit a line table to the .dwo file).
- bool HasSplitTypeUnits = false;
-
/// Separated Dwarf Variables
/// In general these will all be for bits that are left in the
/// original object file, rather than things that are meant
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index 16ce3d7791c..811112a0430 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -85,8 +85,6 @@ DwarfTypeUnit::DwarfTypeUnit(DwarfCompileUnit &CU, AsmPrinter *A,
MCDwarfDwoLineTable *SplitLineTable)
: DwarfUnit(dwarf::DW_TAG_type_unit, CU.getCUNode(), A, DW, DWU), CU(CU),
SplitLineTable(SplitLineTable) {
- if (SplitLineTable)
- addSectionOffset(getUnitDie(), dwarf::DW_AT_stmt_list, 0);
}
DwarfUnit::~DwarfUnit() {
@@ -300,12 +298,15 @@ MD5::MD5Result *DwarfUnit::getMD5AsBytes(const DIFile *File) {
}
unsigned DwarfTypeUnit::getOrCreateSourceID(const DIFile *File) {
- return SplitLineTable
- ? SplitLineTable->getFile(File->getDirectory(),
- File->getFilename(),
- getMD5AsBytes(File),
- File->getSource())
- : getCU().getOrCreateSourceID(File);
+ if (!SplitLineTable)
+ return getCU().getOrCreateSourceID(File);
+ if (!UsedLineTable) {
+ UsedLineTable = true;
+ // This is a split type unit that needs a line table.
+ addSectionOffset(getUnitDie(), dwarf::DW_AT_stmt_list, 0);
+ }
+ return SplitLineTable->getFile(File->getDirectory(), File->getFilename(),
+ getMD5AsBytes(File), File->getSource());
}
void DwarfUnit::addOpAddress(DIELoc &Die, const MCSymbol *Sym) {
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
index 5de39637f52..328e3549e05 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.h
@@ -367,6 +367,7 @@ class DwarfTypeUnit final : public DwarfUnit {
const DIE *Ty;
DwarfCompileUnit &CU;
MCDwarfDwoLineTable *SplitLineTable;
+ bool UsedLineTable = false;
unsigned getOrCreateSourceID(const DIFile *File) override;
bool isDwoUnit() const override;
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 685b46a606d..2da69fe1e4e 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -257,9 +257,12 @@ void MCDwarfLineTable::Emit(MCObjectStreamer *MCOS,
LineStr->emitSection(MCOS);
}
-void MCDwarfDwoLineTable::Emit(MCStreamer &MCOS,
- MCDwarfLineTableParams Params) const {
+void MCDwarfDwoLineTable::Emit(MCStreamer &MCOS, MCDwarfLineTableParams Params,
+ MCSection *Section) const {
+ if (Header.MCDwarfFiles.empty())
+ return;
Optional<MCDwarfLineStr> NoLineStr(None);
+ MCOS.SwitchSection(Section);
MCOS.EmitLabel(Header.Emit(&MCOS, Params, None, NoLineStr).second);
}
OpenPOWER on IntegriCloud