[PATCH] D57250: [DEBUG_INFO][NVPTX]Emit empty .debug_loc section in presence of the debug option.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 25 11:35:11 PST 2019


ABataev created this revision.
ABataev added a reviewer: tra.
Herald added subscribers: aprantl, jholewinski.

If the LLVM module shows that it has debug info, but the file is
actually empty and the real debug info is not emitted, the ptxas tool
emits error 'Debug information not found in presence of .target debug'.
We need at leas one empty debug section to silence this message. Section
`.debug_loc` is not emitted for PTX and we can emit empty `.debug_loc`
section if `debug` option was emitted.


Repository:
  rL LLVM

https://reviews.llvm.org/D57250

Files:
  lib/Target/NVPTX/NVPTXAsmPrinter.cpp
  test/DebugInfo/NVPTX/debug-empty.ll


Index: test/DebugInfo/NVPTX/debug-empty.ll
===================================================================
--- test/DebugInfo/NVPTX/debug-empty.ll
+++ test/DebugInfo/NVPTX/debug-empty.ll
@@ -1,6 +1,7 @@
 ; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda | FileCheck %s
 
 ; CHECK: .target sm_{{[0-9]+$}}
+; CHECK: .section .debug_loc { }
 ; CHECK-NOT: }
 
 !llvm.dbg.cu = !{!0}
Index: lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===================================================================
--- lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -954,9 +954,12 @@
 
   delete[] gv_array;
   // Close the last emitted section
-  if (HasDebugInfo)
+  if (HasDebugInfo) {
     static_cast<NVPTXTargetStreamer *>(OutStreamer->getTargetStreamer())
         ->closeLastSection();
+    // Emit empty .debug_loc section for better support of the empty files.
+    OutStreamer->EmitRawText("\t.section\t.debug_loc\t{\t}");
+  }
 
   // Output last DWARF .file directives, if any.
   static_cast<NVPTXTargetStreamer *>(OutStreamer->getTargetStreamer())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57250.183586.patch
Type: text/x-patch
Size: 1071 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190125/f699e1c1/attachment.bin>


More information about the llvm-commits mailing list