mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-30 19:55:11 +00:00
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
This commit is contained in:
parent
5b2de5dd3d
commit
a07c1ab4e6
@ -345,12 +345,6 @@ namespace llvm {
|
|||||||
void setDwarfCompileUnitID(unsigned CUIndex) {
|
void setDwarfCompileUnitID(unsigned CUIndex) {
|
||||||
DwarfCompileUnitID = 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) {
|
void setMCLineTableCompilationDir(unsigned CUID, StringRef CompilationDir) {
|
||||||
getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
|
getMCDwarfLineTable(CUID).setCompilationDir(CompilationDir);
|
||||||
}
|
}
|
||||||
|
@ -658,6 +658,8 @@ public:
|
|||||||
virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
|
virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
|
||||||
const MCSymbol *Label) {}
|
const MCSymbol *Label) {}
|
||||||
|
|
||||||
|
virtual MCSymbol *getDwarfLineTableSymbol(unsigned CUID);
|
||||||
|
|
||||||
void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
|
void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label,
|
||||||
int PointerSize);
|
int PointerSize);
|
||||||
|
|
||||||
|
@ -2070,13 +2070,7 @@ void DwarfUnit::addRange(RangeSpan Range) {
|
|||||||
void DwarfCompileUnit::initStmtList(MCSymbol *DwarfLineSectionSym) {
|
void DwarfCompileUnit::initStmtList(MCSymbol *DwarfLineSectionSym) {
|
||||||
// Define start line table label for each Compile Unit.
|
// Define start line table label for each Compile Unit.
|
||||||
MCSymbol *LineTableStartSym =
|
MCSymbol *LineTableStartSym =
|
||||||
Asm->GetTempSymbol("line_table_start", getUniqueID());
|
Asm->OutStreamer.getDwarfLineTableSymbol(getUniqueID());
|
||||||
Asm->OutStreamer.getContext().setMCLineTableSymbol(LineTableStartSym,
|
|
||||||
getUniqueID());
|
|
||||||
|
|
||||||
// Use a single line table if we are generating assembly.
|
|
||||||
bool UseTheFirstCU =
|
|
||||||
Asm->OutStreamer.hasRawTextSupport() || (getUniqueID() == 0);
|
|
||||||
|
|
||||||
stmtListIndex = UnitDie->getValues().size();
|
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
|
// The line table entries are not always emitted in assembly, so it
|
||||||
// is not okay to use line_table_start here.
|
// is not okay to use line_table_start here.
|
||||||
if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
|
if (Asm->MAI->doesDwarfUseRelocationsAcrossSections())
|
||||||
addSectionLabel(UnitDie.get(), dwarf::DW_AT_stmt_list,
|
addSectionLabel(UnitDie.get(), dwarf::DW_AT_stmt_list, LineTableStartSym);
|
||||||
UseTheFirstCU ? DwarfLineSectionSym : LineTableStartSym);
|
|
||||||
else if (UseTheFirstCU)
|
|
||||||
addSectionOffset(UnitDie.get(), dwarf::DW_AT_stmt_list, 0);
|
|
||||||
else
|
else
|
||||||
addSectionDelta(UnitDie.get(), dwarf::DW_AT_stmt_list, LineTableStartSym,
|
addSectionDelta(UnitDie.get(), dwarf::DW_AT_stmt_list, LineTableStartSym,
|
||||||
DwarfLineSectionSym);
|
DwarfLineSectionSym);
|
||||||
|
@ -207,6 +207,7 @@ public:
|
|||||||
unsigned Column, unsigned Flags,
|
unsigned Column, unsigned Flags,
|
||||||
unsigned Isa, unsigned Discriminator,
|
unsigned Isa, unsigned Discriminator,
|
||||||
StringRef FileName) override;
|
StringRef FileName) override;
|
||||||
|
MCSymbol *getDwarfLineTableSymbol(unsigned CUID) override;
|
||||||
|
|
||||||
void EmitIdent(StringRef IdentString) override;
|
void EmitIdent(StringRef IdentString) override;
|
||||||
void EmitCFISections(bool EH, bool Debug) override;
|
void EmitCFISections(bool EH, bool Debug) override;
|
||||||
@ -957,6 +958,12 @@ void MCAsmStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
|||||||
EmitEOL();
|
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) {
|
void MCAsmStreamer::EmitIdent(StringRef IdentString) {
|
||||||
assert(MAI->hasIdentDirective() && ".ident directive not supported");
|
assert(MAI->hasIdentDirective() && ".ident directive not supported");
|
||||||
OS << "\t.ident\t";
|
OS << "\t.ident\t";
|
||||||
@ -1442,8 +1449,7 @@ void MCAsmStreamer::FinishImpl() {
|
|||||||
// directly, the label is the only work required here.
|
// directly, the label is the only work required here.
|
||||||
auto &Tables = getContext().getMCDwarfLineTables();
|
auto &Tables = getContext().getMCDwarfLineTables();
|
||||||
if (!Tables.empty()) {
|
if (!Tables.empty()) {
|
||||||
// FIXME: assert Tables.size() == 1 here, except that's not currently true
|
assert(Tables.size() == 1 && "asm output only supports one line table");
|
||||||
// due to DwarfUnit.cpp:2074.
|
|
||||||
if (auto *Label = Tables.begin()->second.getLabel()) {
|
if (auto *Label = Tables.begin()->second.getLabel()) {
|
||||||
SwitchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
|
SwitchSection(getContext().getObjectFileInfo()->getDwarfLineSection());
|
||||||
EmitLabel(Label);
|
EmitLabel(Label);
|
||||||
|
@ -788,10 +788,8 @@ void MCGenDwarfInfo::Emit(MCStreamer *MCOS) {
|
|||||||
bool CreateDwarfSectionSymbols =
|
bool CreateDwarfSectionSymbols =
|
||||||
AsmInfo->doesDwarfUseRelocationsAcrossSections();
|
AsmInfo->doesDwarfUseRelocationsAcrossSections();
|
||||||
MCSymbol *LineSectionSymbol = nullptr;
|
MCSymbol *LineSectionSymbol = nullptr;
|
||||||
if (CreateDwarfSectionSymbols) {
|
if (CreateDwarfSectionSymbols)
|
||||||
LineSectionSymbol = context.CreateTempSymbol();
|
LineSectionSymbol = MCOS->getDwarfLineTableSymbol(0);
|
||||||
context.setMCLineTableSymbol(LineSectionSymbol, 0);
|
|
||||||
}
|
|
||||||
MCSymbol *AbbrevSectionSymbol = NULL;
|
MCSymbol *AbbrevSectionSymbol = NULL;
|
||||||
MCSymbol *InfoSectionSymbol = NULL;
|
MCSymbol *InfoSectionSymbol = NULL;
|
||||||
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfInfoSection());
|
MCOS->SwitchSection(context.getObjectFileInfo()->getDwarfInfoSection());
|
||||||
|
@ -191,6 +191,16 @@ void MCStreamer::EmitDwarfLocDirective(unsigned FileNo, unsigned Line,
|
|||||||
Discriminator);
|
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() {
|
MCDwarfFrameInfo *MCStreamer::getCurrentFrameInfo() {
|
||||||
if (FrameInfos.empty())
|
if (FrameInfos.empty())
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -17,7 +17,7 @@ target triple = "thumbv7-apple-darwin10"
|
|||||||
; DW_OP_constu
|
; DW_OP_constu
|
||||||
; offset
|
; offset
|
||||||
|
|
||||||
;CHECK: .long Lset6
|
;CHECK: .long Lset7
|
||||||
;CHECK-NEXT: @ DW_AT_type
|
;CHECK-NEXT: @ DW_AT_type
|
||||||
;CHECK-NEXT: @ DW_AT_decl_file
|
;CHECK-NEXT: @ DW_AT_decl_file
|
||||||
;CHECK-NEXT: @ DW_AT_decl_line
|
;CHECK-NEXT: @ DW_AT_decl_line
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
; DW_OP_constu
|
; DW_OP_constu
|
||||||
; offset
|
; offset
|
||||||
|
|
||||||
;CHECK: .long Lset8
|
;CHECK: .long Lset9
|
||||||
;CHECK-NEXT: @ DW_AT_type
|
;CHECK-NEXT: @ DW_AT_type
|
||||||
;CHECK-NEXT: @ DW_AT_decl_file
|
;CHECK-NEXT: @ DW_AT_decl_file
|
||||||
;CHECK-NEXT: @ DW_AT_decl_line
|
;CHECK-NEXT: @ DW_AT_decl_line
|
||||||
|
@ -51,9 +51,11 @@
|
|||||||
|
|
||||||
; PR15408
|
; PR15408
|
||||||
; ASM: L__DWARF__debug_info_begin0:
|
; 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: 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 {
|
define i32 @test(i32 %a) nounwind uwtable ssp {
|
||||||
entry:
|
entry:
|
||||||
%a.addr = alloca i32, align 4
|
%a.addr = alloca i32, align 4
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
; CHECK: .section .debug_line,"",@progbits
|
; CHECK: .section .debug_line,"",@progbits
|
||||||
; CHECK-NEXT: .Lsection_line:
|
; CHECK-NEXT: .Lsection_line:
|
||||||
|
|
||||||
; CHECK: .long .Lsection_line # DW_AT_stmt_list
|
; CHECK: .long .Lline_table_start0 # DW_AT_stmt_list
|
||||||
|
|
||||||
define void @f() {
|
define void @f() {
|
||||||
entry:
|
entry:
|
||||||
|
@ -39,7 +39,7 @@ foo:
|
|||||||
// ASM-NEXT: .long [[ABBREV_LABEL]]
|
// ASM-NEXT: .long [[ABBREV_LABEL]]
|
||||||
// First .byte 1 is the abbreviation number for the compile_unit abbrev
|
// First .byte 1 is the abbreviation number for the compile_unit abbrev
|
||||||
// ASM: .byte 1
|
// 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: .section .debug_line
|
||||||
// ASM-NEXT: [[LINE_LABEL]]
|
// ASM-NEXT: [[LINE_LABEL]]
|
||||||
|
Loading…
Reference in New Issue
Block a user