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

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
This commit is contained in:
Alexey Bataev 2019-03-08 20:08:04 +00:00
parent bcd58e4ff6
commit c30eca2a72
2 changed files with 5 additions and 1 deletions

View 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())

View 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}