Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,8 +352,6 @@ DwarfDebug::DwarfDebug(AsmPrinter *A)
else
UseInlineStrings = DwarfInlinedStrings == Enable;

UseLocSection = !TT.isNVPTX();

// Always emit .debug_aranges for SCE tuning.
UseARangesSection = GenerateARangeSection || tuneForSCE();

Expand Down Expand Up @@ -1324,7 +1322,12 @@ void DwarfDebug::finalizeModuleInfo() {
// ranges for all subprogram DIEs for mach-o.
DwarfCompileUnit &U = SkCU ? *SkCU : TheCU;

if (unsigned NumRanges = TheCU.getRanges().size()) {
if (Asm->TM.getTargetTriple().isNVPTX() && tuneForGDB()) {
// PTX does not support subtracting labels from the code section in the
// debug_loc section. To work around this, the NVPTX backend needs the
// compile unit to have no low_pc in order to have a zero base_address
// when handling debug_loc in cuda-gdb.
Comment on lines +1326 to +1329
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These if/else blocks read a bit weird. Better collapse them into a single if condition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved the PTX test inside the other block, which is probably easier to read. I don't want to merge the two conditions, exactly, since one is an assignment, and a type-preserving merge would be ugly there.

} else if (unsigned NumRanges = TheCU.getRanges().size()) {
if (NumRanges > 1 && useRangesSection())
// A DW_AT_low_pc attribute may also be specified in combination with
// DW_AT_ranges to specify the default base address for use in
Expand Down Expand Up @@ -1920,10 +1923,6 @@ void DwarfDebug::collectEntityInfo(DwarfCompileUnit &TheCU,
}
}

// Do not emit location lists if .debug_loc secton is disabled.
if (!useLocSection())
continue;

// Handle multiple DBG_VALUE instructions describing one variable.
DebugLocStream::ListBuilder List(DebugLocs, TheCU, *Asm, *RegVar);

Expand Down Expand Up @@ -2841,7 +2840,17 @@ static void emitRangeList(
bool BaseIsSet = false;
for (const auto &P : SectionRanges) {
auto *Base = CUBase;
if (!Base && ShouldUseBaseAddress) {
if ((Asm->TM.getTargetTriple().isNVPTX() && DD.tuneForGDB())) {
// PTX does not support subtracting labels from the code section in the
// debug_loc section. To work around this, the NVPTX backend needs the
// compile unit to have no low_pc in order to have a zero base_address
// when handling debug_loc in cuda-gdb. Additionally, cuda-gdb doesn't
// seem to handle setting a per-variable base to zero. To make cuda-gdb
// happy, just emit labels with no base while having no compile unit
// low_pc.
BaseIsSet = false;
Base = nullptr;
} else if (!Base && ShouldUseBaseAddress) {
const MCSymbol *Begin = P.second.front()->Begin;
const MCSymbol *NewBase = DD.getSectionLabel(&Begin->getSection());
if (!UseDwarf5) {
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,6 @@ class DwarfDebug : public DebugHandlerBase {
/// temp symbols inside DWARF sections.
bool UseSectionsAsReferences = false;

///Allow emission of the .debug_loc section.
bool UseLocSection = true;

/// Allow emission of .debug_aranges section
bool UseARangesSection = false;

Expand Down Expand Up @@ -791,9 +788,6 @@ class DwarfDebug : public DebugHandlerBase {
return UseSectionsAsReferences;
}

/// Returns whether .debug_loc section should be emitted.
bool useLocSection() const { return UseLocSection; }

/// Returns whether to generate DWARF v4 type units.
bool generateTypeUnits() const { return GenerateTypeUnits; }

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,8 +964,8 @@ bool NVPTXAsmPrinter::doFinalization(Module &M) {
// Close the last emitted section
if (hasDebugInfo()) {
TS->closeLastSection();
// Emit empty .debug_loc section for better support of the empty files.
OutStreamer->emitRawText("\t.section\t.debug_loc\t{\t}");
// Emit empty .debug_macinfo section for better support of the empty files.
OutStreamer->emitRawText("\t.section\t.debug_macinfo\t{\t}");
}

// Output last DWARF .file directives, if any.
Expand Down
256 changes: 125 additions & 131 deletions llvm/test/DebugInfo/NVPTX/cu-range-hole.ll

Large diffs are not rendered by default.

292 changes: 143 additions & 149 deletions llvm/test/DebugInfo/NVPTX/dbg-declare-alloca.ll

Large diffs are not rendered by default.

598 changes: 296 additions & 302 deletions llvm/test/DebugInfo/NVPTX/debug-addr-class.ll

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion llvm/test/DebugInfo/NVPTX/debug-empty.ll
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64-nvidia-cuda | %ptxas-verify %}

; CHECK: .target sm_{{[0-9]+$}}
; CHECK: .section .debug_loc { }
; CHECK: .section .debug_macinfo { }
; CHECK-NOT: }

!llvm.dbg.cu = !{!0}
Expand Down
72 changes: 33 additions & 39 deletions llvm/test/DebugInfo/NVPTX/debug-file-loc.ll
Original file line number Diff line number Diff line change
Expand Up @@ -30,49 +30,45 @@ bb:

; CHECK-DAG: .file [[FOO]] "/source/dir{{/|\\\\}}foo.h"
; CHECK-DAG: .file [[BAR]] "/source/dir{{/|\\\\}}bar.cu"
; CHECK: .section .debug_abbrev
; CHECK-NEXT: {
; CHECK-NEXT: .b8 1 // Abbreviation Code
; CHECK-NEXT: .b8 17 // DW_TAG_compile_unit
; CHECK-NEXT: .b8 0 // DW_CHILDREN_no
; CHECK-NEXT: .b8 37 // DW_AT_producer
; CHECK-NEXT: .b8 8 // DW_FORM_string
; CHECK-NEXT: .b8 19 // DW_AT_language
; CHECK-NEXT: .b8 5 // DW_FORM_data2
; CHECK-NEXT: .b8 3 // DW_AT_name
; CHECK-NEXT: .b8 8 // DW_FORM_string
; CHECK-NEXT: .b8 16 // DW_AT_stmt_list
; CHECK-NEXT: .b8 6 // DW_FORM_data4
; CHECK-NEXT: .b8 27 // DW_AT_comp_dir
; CHECK-NEXT: .b8 8 // DW_FORM_string
; CHECK-NEXT: .b8 17 // DW_AT_low_pc
; CHECK-NEXT: .b8 1 // DW_FORM_addr
; CHECK-NEXT: .b8 18 // DW_AT_high_pc
; CHECK-NEXT: .b8 1 // DW_FORM_addr
; CHECK-NEXT: .b8 0 // EOM(1)
; CHECK-NEXT: .b8 0 // EOM(2)
; CHECK-NEXT: .b8 0 // EOM(3)
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_info
; CHECK-NEXT: {
; CHECK-NEXT: .b32 50 // Length of Unit
; CHECK-NEXT: .b8 2 // DWARF version number
; CHECK: .section .debug_abbrev
; CHECK-NEXT: {
; CHECK-NEXT: .b8 1 // Abbreviation Code
; CHECK-NEXT: .b8 17 // DW_TAG_compile_unit
; CHECK-NEXT: .b8 0 // DW_CHILDREN_no
; CHECK-NEXT: .b8 37 // DW_AT_producer
; CHECK-NEXT: .b8 8 // DW_FORM_string
; CHECK-NEXT: .b8 19 // DW_AT_language
; CHECK-NEXT: .b8 5 // DW_FORM_data2
; CHECK-NEXT: .b8 3 // DW_AT_name
; CHECK-NEXT: .b8 8 // DW_FORM_string
; CHECK-NEXT: .b8 16 // DW_AT_stmt_list
; CHECK-NEXT: .b8 6 // DW_FORM_data4
; CHECK-NEXT: .b8 27 // DW_AT_comp_dir
; CHECK-NEXT: .b8 8 // DW_FORM_string
; CHECK-NEXT: .b8 0 // EOM(1)
; CHECK-NEXT: .b8 0 // EOM(2)
; CHECK-NEXT: .b8 0 // EOM(3)
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_info
; CHECK-NEXT: {
; CHECK-NEXT: .b32 34 // Length of Unit
; CHECK-NEXT: .b8 2 // DWARF version number
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b32 .debug_abbrev // Offset Into Abbrev. Section
; CHECK-NEXT: .b8 8 // Address Size (in bytes)
; CHECK-NEXT: .b8 1 // Abbrev [1] 0xb:0x2b DW_TAG_compile_unit
; CHECK-NEXT: .b8 0 // DW_AT_producer
; CHECK-NEXT: .b8 4 // DW_AT_language
; CHECK-NEXT: .b32 .debug_abbrev // Offset Into Abbrev. Section
; CHECK-NEXT: .b8 8 // Address Size (in bytes)
; CHECK-NEXT: .b8 1 // Abbrev [1] 0xb:0x1b DW_TAG_compile_unit
; CHECK-NEXT: .b8 0 // DW_AT_producer
; CHECK-NEXT: .b8 4 // DW_AT_language
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b8 98 // DW_AT_name
; CHECK-NEXT: .b8 98 // DW_AT_name
; CHECK-NEXT: .b8 97
; CHECK-NEXT: .b8 114
; CHECK-NEXT: .b8 46
; CHECK-NEXT: .b8 99
; CHECK-NEXT: .b8 117
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b32 .debug_line // DW_AT_stmt_list
; CHECK-NEXT: .b8 47 // DW_AT_comp_dir
; CHECK-NEXT: .b32 .debug_line // DW_AT_stmt_list
; CHECK-NEXT: .b8 47 // DW_AT_comp_dir
; CHECK-NEXT: .b8 115
; CHECK-NEXT: .b8 111
; CHECK-NEXT: .b8 117
Expand All @@ -84,10 +80,8 @@ bb:
; CHECK-NEXT: .b8 105
; CHECK-NEXT: .b8 114
; CHECK-NEXT: .b8 0
; CHECK-NEXT: .b64 $L__func_begin0 // DW_AT_low_pc
; CHECK-NEXT: .b64 $L__func_end1 // DW_AT_high_pc
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_loc { }
; CHECK-NEXT: }
; CHECK-NEXT: .section .debug_macinfo { }
; CHECK-NOT: debug_

!llvm.dbg.cu = !{!0}
Expand Down
Loading
Loading