summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/MC/MCContext.h6
-rw-r--r--include/llvm/MC/MCStreamer.h2
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfUnit.cpp13
-rw-r--r--lib/MC/MCAsmStreamer.cpp10
-rw-r--r--lib/MC/MCDwarf.cpp6
-rw-r--r--lib/MC/MCStreamer.cpp10
-rw-r--r--test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll2
-rw-r--r--test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll2
-rw-r--r--test/DebugInfo/X86/stmt-list-multiple-compile-units.ll6
-rw-r--r--test/DebugInfo/X86/stmt-list.ll2
-rw-r--r--test/MC/ELF/gen-dwarf.s2
11 files changed, 32 insertions, 29 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h
index b276b1f83e..9091ed93e5 100644
--- a/include/llvm/MC/MCContext.h
+++ b/include/llvm/MC/MCContext.h
@@ -345,12 +345,6 @@ namespace llvm {
void setDwarfCompileUnitID(unsigned CUIndex) {
DwarfCompileUnitID = CUIndex;
}
- MCSymbol *getMCLineTableSymbol(unsigned ID) const {
- return getMCDwarfLineTable(ID).getLabel();
- }
- void setMCLineTableSymbol(MCSymbol *Sym, unsigned ID) {
- getMCDwarfLineTable(ID).setLabel(Sym);
- }
void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir) {
getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
}
diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h
index 33437bda80..8ee60c1851 100644
--- a/include/llvm/MC/MCStreamer.h
+++ b/include/llvm/MC/MCStreamer.h
@@ -658,6 +658,8 @@ public:
virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
const MCSymbol *Label) {}
+ virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
+
void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
int PointerSize);
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;
diff --git a/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll b/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll
index 93f9bffe86..b1d59aa0fd 100644
--- a/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll
+++ b/test/CodeGen/ARM/2011-01-19-MergedGlobalDbg.ll
@@ -17,7 +17,7 @@ target triple = "thumbv7-apple-darwin10"
; DW_OP_constu
; offset
-;CHECK: .long Lset6
+;CHECK: .long Lset7
;CHECK-NEXT: @ DW_AT_type
;CHECK-NEXT: @ DW_AT_decl_file
;CHECK-NEXT: @ DW_AT_decl_line
diff --git a/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll b/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll
index 0100f2af4f..ed2840bbff 100644
--- a/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll
+++ b/test/CodeGen/ARM/2011-08-02-MergedGlobalDbg.ll
@@ -8,7 +8,7 @@
; DW_OP_constu
; offset
-;CHECK: .long Lset8
+;CHECK: .long Lset9
;CHECK-NEXT: @ DW_AT_type
;CHECK-NEXT: @ DW_AT_decl_file
;CHECK-NEXT: @ DW_AT_decl_line
diff --git a/test/DebugInfo/X86/stmt-list-multiple-compile-units.ll b/test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
index 344d063266..8816fe77cf 100644
--- a/test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
+++ b/test/DebugInfo/X86/stmt-list-multiple-compile-units.ll
@@ -51,9 +51,11 @@
; PR15408
; ASM: L__DWARF__debug_info_begin0:
-; ASM: .long 0 ## DW_AT_stmt_list
+; ASM: Lset3 = Lline_table_start0-Lsection_line ## DW_AT_stmt_list
+; ASM-NEXT: .long Lset3
; ASM: L__DWARF__debug_info_begin1:
-; ASM: .long 0 ## DW_AT_stmt_list
+; ASM: Lset13 = Lline_table_start0-Lsection_line ## DW_AT_stmt_list
+; ASM-NEXT: .long Lset13
define i32 @test(i32 %a) nounwind uwtable ssp {
entry:
%a.addr = alloca i32, align 4
diff --git a/test/DebugInfo/X86/stmt-list.ll b/test/DebugInfo/X86/stmt-list.ll
index 6f846c1589..99bd0fc1b5 100644
--- a/test/DebugInfo/X86/stmt-list.ll
+++ b/test/DebugInfo/X86/stmt-list.ll
@@ -3,7 +3,7 @@
; CHECK: .section .debug_line,"",@progbits
; CHECK-NEXT: .Lsection_line:
-; CHECK: .long .Lsection_line # DW_AT_stmt_list
+; CHECK: .long .Lline_table_start0 # DW_AT_stmt_list
define void @f() {
entry:
diff --git a/test/MC/ELF/gen-dwarf.s b/test/MC/ELF/gen-dwarf.s
index e83b14c4e3..946119bb24 100644
--- a/test/MC/ELF/gen-dwarf.s
+++ b/test/MC/ELF/gen-dwarf.s
@@ -39,7 +39,7 @@ foo:
// ASM-NEXT: .long [[ABBREV_LABEL]]
// First .byte 1 is the abbreviation number for the compile_unit abbrev
// ASM: .byte 1
-// ASM-NEXT: .long [[LINE_LABEL:.Ltmp[0-9]+]]
+// ASM-NEXT: .long [[LINE_LABEL:.L[a-z0-9]+]]
// ASM: .section .debug_line
// ASM-NEXT: [[LINE_LABEL]]