From c30eca2a728d6c9b1ac09833dc8e0e8f0039c536 Mon Sep 17 00:00:00 2001 From: Alexey Bataev Date: Fri, 8 Mar 2019 20:08:04 +0000 Subject: [PATCH] [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 --- lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 5 ++++- test/DebugInfo/NVPTX/debug-empty.ll | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 274f1c59b6c..5c840e5cc7c 100644 --- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -954,9 +954,12 @@ bool NVPTXAsmPrinter::doFinalization(Module &M) { delete[] gv_array; // Close the last emitted section - if (HasDebugInfo) + if (HasDebugInfo) { static_cast(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(OutStreamer->getTargetStreamer()) diff --git a/test/DebugInfo/NVPTX/debug-empty.ll b/test/DebugInfo/NVPTX/debug-empty.ll index f1ebf739d2f..cae258815e4 100644 --- a/test/DebugInfo/NVPTX/debug-empty.ll +++ b/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} -- 2.50.1