diff options
author | David Blaikie <dblaikie@gmail.com> | 2014-04-01 08:07:52 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2014-04-01 08:07:52 +0000 |
commit | a07c1ab4e6870af37eb183c46765dd1057c00b63 (patch) | |
tree | 1e66211cafb975e0b096ba1147d5cf0e2951f8c5 /lib | |
parent | 5b2de5dd3d46b54788abe8ec920561484da44f02 (diff) | |
download | llvm-a07c1ab4e6870af37eb183c46765dd1057c00b63.tar.gz llvm-a07c1ab4e6870af37eb183c46765dd1057c00b63.tar.bz2 llvm-a07c1ab4e6870af37eb183c46765dd1057c00b63.tar.xz |
DebugInfo: Avoid creating unnecessary/empty line tables and remove the special case of '0' in DwarfCompileUnit::initStmtList by just always using a label difference
This moves one case of raw text checking down into the MCStreamer
interfaces in the form of a virtual function, even if we ultimately end
up consolidating on the one-or-many line tables issue one day, this is
nicer in the interim. This just generally streamlines a bunch of use
cases into a common code path.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@205287 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 13 | ||||
-rw-r--r-- | lib/MC/MCAsmStreamer.cpp | 10 | ||||
-rw-r--r-- | lib/MC/MCDwarf.cpp | 6 | ||||
-rw-r--r-- | lib/MC/MCStreamer.cpp | 10 |
4 files changed, 22 insertions, 17 deletions
diff --git a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index eaf0a17f05..dc3917b585 100644 --- a/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -2070,13 +2070,7 @@ void DwarfUnit::addRange(RangeSpan Range) { void DwarfCompileUnit::initStmtList(MCSymbol *DwarfLineSectionSym) { // Define start line table label for each Compile Unit. MCSymbol *LineTableStartSym = - Asm->GetTempSymbol("line_table_start", getUniqueID()); - Asm->OutStreamer.getContext().setMCLineTableSymbol(LineTableStartSym, - getUniqueID()); - - // Use a single line table if we are generating assembly. - bool UseTheFirstCU = - Asm->OutStreamer.hasRawTextSupport() || (getUniqueID() == 0); + Asm->OutStreamer.getDwarfLineTableSymbol(getUniqueID()); stmtListIndex = UnitDie->getValues().size(); @@ -2086,10 +2080,7 @@ void DwarfCompileUnit::initStmtList(MCSymbol *DwarfLineSectionSym) { // The line table entries are not always emitted in assembly, so it // is not okay to use line_table_start here. if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) - addSectionLabel(UnitDie.get(), dwarf::DW_AT_stmt_list, - UseTheFirstCU ? DwarfLineSectionSym : LineTableStartSym); - else if (UseTheFirstCU) - addSectionOffset(UnitDie.get(), dwarf::DW_AT_stmt_list, 0); + addSectionLabel(UnitDie.get(), dwarf::DW_AT_stmt_list, LineTableStartSym); else addSectionDelta(UnitDie.get(), dwarf::DW_AT_stmt_list, LineTableStartSym, DwarfLineSectionSym); diff --git a/lib/MC/MCAsmStreamer.cpp b/lib/MC/MCAsmStreamer.cpp index fa54c1a8da..884ccf9299 100644 --- a/lib/MC/MCAsmStreamer.cpp +++ b/lib/MC/MCAsmStreamer.cpp @@ -207,6 +207,7 @@ public: unsigned Column, unsigned Flags, unsigned Isa, unsigned Discriminator, StringRef FileName) override; + MCSymbol *getDwarfLineTableSymbol(unsigned CUID) override; void EmitIdent(StringRef IdentString) override; void EmitCFISections(bool EH, bool Debug) override; @@ -957,6 +958,12 @@ void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line, EmitEOL(); } +MCSymbol *MCAsmStreamer::getDwarfLineTableSymbol(unsigned CUID) { + // Always use the zeroth line table, since asm syntax only supports one line + // table for now. + return MCStreamer::getDwarfLineTableSymbol(0); +} + void MCAsmStreamer::EmitIdent(StringRef IdentString) { assert(MAI->hasIdentDirective() && ".ident directive not supported"); OS << "\t.ident\t"; @@ -1442,8 +1449,7 @@ void MCAsmStreamer::FinishImpl() { // directly, the label is the only work required here. auto &Tables = getContext().getMCDwarfLineTables(); if (!Tables.empty()) { - // FIXME: assert Tables.size() == 1 here, except that's not currently true - // due to DwarfUnit.cpp:2074. + assert(Tables.size() == 1 && "asm output only supports one line table"); if (auto *Label = Tables.begin()->second.getLabel()) { SwitchSection(getContext().getObjectFileInfo()->getDwarfLineSection()); EmitLabel(Label); diff --git a/lib/MC/MCDwarf.cpp b/lib/MC/MCDwarf.cpp index 231948eaff..72836ff32e 100644 --- a/lib/MC/MCDwarf.cpp +++ b/lib/MC/MCDwarf.cpp @@ -788,10 +788,8 @@ void MCGenDwarfInfo::Emit(MCStreamer *MCOS) { bool CreateDwarfSectionSymbols = AsmInfo->doesDwarfUseRelocationsAcrossSections(); MCSymbol *LineSectionSymbol = nullptr; - if (CreateDwarfSectionSymbols) { - LineSectionSymbol = context.CreateTempSymbol(); - context.setMCLineTableSymbol(LineSectionSymbol, 0); - } + if (CreateDwarfSectionSymbols) + LineSectionSymbol = MCOS->getDwarfLineTableSymbol(0); MCSymbol *AbbrevSectionSymbol = NULL; MCSymbol *InfoSectionSymbol = NULL; MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfInfoSection()); diff --git a/lib/MC/MCStreamer.cpp b/lib/MC/MCStreamer.cpp index 0558a58abf..8fa55aa59e 100644 --- a/lib/MC/MCStreamer.cpp +++ b/lib/MC/MCStreamer.cpp @@ -191,6 +191,16 @@ void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line, Discriminator); } +MCSymbol *MCStreamer::getDwarfLineTableSymbol(unsigned CUID) { + MCDwarfLineTable &Table = getContext().getMCDwarfLineTable(CUID); + if (!Table.getLabel()) { + StringRef Prefix = Context.getAsmInfo()->getPrivateGlobalPrefix(); + Table.setLabel( + Context.GetOrCreateSymbol(Prefix + "line_table_start" + Twine(CUID))); + } + return Table.getLabel(); +} + MCDwarfFrameInfo *MCStreamer::getCurrentFrameInfo() { if (FrameInfos.empty()) return 0; |