Index: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -954,9 +954,12 @@ 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()) Index: llvm/trunk/test/DebugInfo/NVPTX/debug-empty.ll =================================================================== --- llvm/trunk/test/DebugInfo/NVPTX/debug-empty.ll +++ llvm/trunk/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}