[all-commits] [llvm/llvm-project] ae635d: [NVPTX] add support for .debug_loc section (#110905)

William G Hatch via All-commits all-commits at lists.llvm.org
Thu Oct 3 15:32:10 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ae635d6f997a28c81a01bfffe70fd849d0eafcca
      https://github.com/llvm/llvm-project/commit/ae635d6f997a28c81a01bfffe70fd849d0eafcca
  Author: William G Hatch <william at hatch.uno>
  Date:   2024-10-03 (Thu, 03 Oct 2024)

  Changed paths:
    M llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
    M llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
    M llvm/test/DebugInfo/NVPTX/cu-range-hole.ll
    M llvm/test/DebugInfo/NVPTX/dbg-declare-alloca.ll
    M llvm/test/DebugInfo/NVPTX/debug-addr-class.ll
    M llvm/test/DebugInfo/NVPTX/debug-empty.ll
    M llvm/test/DebugInfo/NVPTX/debug-file-loc.ll
    M llvm/test/DebugInfo/NVPTX/debug-info.ll
    M llvm/test/DebugInfo/NVPTX/debug-loc-offset.ll

  Log Message:
  -----------
  [NVPTX] add support for .debug_loc section (#110905)

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.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list