summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MCDwarf.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-04-01 07:35:52 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-04-01 07:35:52 +0000
commit8bf66c4f3ff38bfe50a2855a7e48fc8d4bd026a5 (patch)
tree5d42e6e99090c1213e3831d3701d70d6befaace4 /llvm/lib/MC/MCDwarf.cpp
parent8d265c26338559eb14bb21a1902d44a1d89bb055 (diff)
downloadbcm5719-llvm-8bf66c4f3ff38bfe50a2855a7e48fc8d4bd026a5.tar.gz
bcm5719-llvm-8bf66c4f3ff38bfe50a2855a7e48fc8d4bd026a5.zip
DebugInfo: Emit relocation to debug_line section when emitting asm for asm
I don't think this is reachable by any frontend (why would you transform asm to asm+debug info?) but it helps tidy up some of this code, avoid the weird special case of "emit the first CU, store the label, then emit the rest" in MCDwarfLineTable::Emit by instead having the DWARF-for-assembly case use the same codepath as DwarfDebug.cpp, by registering the label of the debug_line section, thus causing it to be emitted. (with a special case in asm output to just emit the label since asm output uses the .loc directives, etc, rather than the debug_loc directly) llvm-svn: 205286
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r--llvm/lib/MC/MCDwarf.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 5fa8f66422b..231948eaff5 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -204,24 +204,22 @@ EmitDwarfLineTable(MCStreamer *MCOS, const MCSection *Section,
//
// This emits the Dwarf file and the line tables.
//
-const MCSymbol *MCDwarfLineTable::Emit(MCStreamer *MCOS) {
+void MCDwarfLineTable::Emit(MCStreamer *MCOS) {
MCContext &context = MCOS->getContext();
- // CUID and MCLineTableSymbols are set in DwarfDebug, when DwarfDebug does
- // not exist, CUID will be 0 and MCLineTableSymbols will be empty.
- // Handle Compile Unit 0, the line table start symbol is the section symbol.
- auto I = MCOS->getContext().getMCDwarfLineTables().begin(),
- E = MCOS->getContext().getMCDwarfLineTables().end();
+ auto &LineTables = context.getMCDwarfLineTables();
+
+ // Bail out early so we don't switch to the debug_line section needlessly and
+ // in doing so create an unnecessary (if empty) section.
+ if (LineTables.empty())
+ return;
// Switch to the section where the table will be emitted into.
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfLineSection());
- const MCSymbol *LineStartSym = I->second.EmitCU(MCOS);
// Handle the rest of the Compile Units.
- for (++I; I != E; ++I)
- I->second.EmitCU(MCOS);
-
- return LineStartSym;
+ for (const auto &CUIDTablePair : LineTables)
+ CUIDTablePair.second.EmitCU(MCOS);
}
void MCDwarfDwoLineTable::Emit(MCStreamer &MCOS) const {
@@ -320,10 +318,8 @@ MCDwarfLineTableHeader::Emit(MCStreamer *MCOS,
return std::make_pair(LineStartSym, LineEndSym);
}
-const MCSymbol *MCDwarfLineTable::EmitCU(MCStreamer *MCOS) const {
- MCSymbol *LineStartSym;
- MCSymbol *LineEndSym;
- std::tie(LineStartSym, LineEndSym) = Header.Emit(MCOS);
+void MCDwarfLineTable::EmitCU(MCStreamer *MCOS) const {
+ MCSymbol *LineEndSym = Header.Emit(MCOS).second;
// Put out the line tables.
for (const auto &LineSec : MCLineSections.getMCLineEntries())
@@ -344,8 +340,6 @@ const MCSymbol *MCDwarfLineTable::EmitCU(MCStreamer *MCOS) const {
// This is the end of the section, so set the value of the symbol at the end
// of this section (that was used in a previous expression).
MCOS->EmitLabel(LineEndSym);
-
- return LineStartSym;
}
unsigned MCDwarfLineTable::getFile(StringRef &Directory, StringRef &FileName,
@@ -787,14 +781,17 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
// When generating dwarf for assembly source files this emits the Dwarf
// sections.
//
-void MCGenDwarfInfo::Emit(MCStreamer *MCOS, const MCSymbol *LineSectionSymbol) {
+void MCGenDwarfInfo::Emit(MCStreamer *MCOS) {
// Create the dwarf sections in this order (.debug_line already created).
MCContext &context = MCOS->getContext();
const MCAsmInfo *AsmInfo = context.getAsmInfo();
bool CreateDwarfSectionSymbols =
AsmInfo->doesDwarfUseRelocationsAcrossSections();
- if (!CreateDwarfSectionSymbols)
- LineSectionSymbol = NULL;
+ MCSymbol *LineSectionSymbol = nullptr;
+ if (CreateDwarfSectionSymbols) {
+ LineSectionSymbol = context.CreateTempSymbol();
+ context.setMCLineTableSymbol(LineSectionSymbol, 0);
+ }
MCSymbol *AbbrevSectionSymbol = NULL;
MCSymbol *InfoSectionSymbol = NULL;
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfInfoSection());
OpenPOWER on IntegriCloud