]> granicus.if.org Git - llvm/commitdiff
[DEBUG_INFO][NVPTX]Emit empty .debug_loc section in presence of the debug option.
authorAlexey Bataev <a.bataev@hotmail.com>
Fri, 8 Mar 2019 20:08:04 +0000 (20:08 +0000)
committerAlexey Bataev <a.bataev@hotmail.com>
Fri, 8 Mar 2019 20:08:04 +0000 (20:08 +0000)
Summary:
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.

Reviewers: tra

Subscribers: jholewinski, aprantl, llvm-commits

Differential Revision: https://reviews.llvm.org/D57250

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355719 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 274f1c59b6cc1a71fa2240557c2448ad3209e0a7..5c840e5cc7c304e828c7d7af503651666ae687f2 100644 (file)
@@ -954,9 +954,12 @@ bool NVPTXAsmPrinter::doFinalization(Module &M) {
 
   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())
index f1ebf739d2fd39cf045ec62b89bbfe54a88c9b89..cae258815e4e0a5290ac96eabc9b541f5c5da4d2 100644 (file)
@@ -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}