
Enable .debug_loc section for NVPTX backend. This commit makes NVPTX omit DW_AT_low_pc (and DW_AT_high_pc) for DW_TAG_compile_unit. This is because cuda-gdb uses the compile unit's low_pc as a base address, and adds the addresses in the debug_loc section to it. Removing low_pc is equivalent to setting that base address to zero, so addition doesn't break the location ranges. Additionally, this patch forces debug_loc label emission to emit single labels with no subtraction or base. This would not be necessary if we could emit `label1 - label2` expressions in PTX. The PTX documentation at https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-section makes it seem like this is supported, but it doesn't actually work. I believe when that documentation says that you can subtract “label addresses between labels in the same dwarf section”, it doesn't merely mean that the labels need to be in the same section as each other, but in fact they need to be in the same section as the use. If support for label subtraction is supported such that in the debug_loc section you can subtract labels from the main code section, then we can remove the workarounds added in this PR. Also, since this now emits valid .debug_loc sections, it replaces the empty .debug_loc to force existence of at least one debug section with an empty .debug_macinfo section, which matches what nvcc does.
21 lines
876 B
LLVM
21 lines
876 B
LLVM
; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda | FileCheck %s
|
|
; RUN: %if ptxas %{ llc < %s -mtriple=nvptx64-nvidia-cuda | %ptxas-verify %}
|
|
|
|
; CHECK: .target sm_{{[0-9]+$}}
|
|
; CHECK: .section .debug_macinfo { }
|
|
; CHECK-NOT: }
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!3, !4, !5, !6, !7}
|
|
!llvm.ident = !{!8}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (trunk 351924) (llvm/trunk 351968)", isOptimized: false, runtimeVersion: 0, emissionKind: DebugDirectivesOnly, enums: !2, nameTableKind: None)
|
|
!1 = !DIFile(filename: "new.cc", directory: "/test")
|
|
!2 = !{}
|
|
!3 = !{i32 2, !"Dwarf Version", i32 2}
|
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
|
!5 = !{i32 1, !"wchar_size", i32 4}
|
|
!6 = !{i32 4, !"nvvm-reflect-ftz", i32 0}
|
|
!7 = !{i32 7, !"PIC Level", i32 2}
|
|
!8 = !{!"clang version 9.0.0 (trunk 351924) (llvm/trunk 351968)"}
|