[llvm] r304004 - DebugInfo: Don't include locations for debug-having code inlined into nodebug functions

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri May 26 10:05:16 PDT 2017


Author: dblaikie
Date: Fri May 26 12:05:15 2017
New Revision: 304004

URL: http://llvm.org/viewvc/llvm-project?rev=304004&view=rev
Log:
DebugInfo: Don't include locations for debug-having code inlined into nodebug functions

This produced 'strange' DWARF anyway - the CU would have no ranges (or
at least not a range including the inlined code) nor any subprogram or
inlined_subroutine - yet the line table would have entries for these
instructions.

(this actually becomes more relevant with changes coming after this,
where a CU without any contents will be omitted entirely - so there
would be no line table to put this on anyway)

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    llvm/trunk/test/DebugInfo/Generic/nodebug.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=304004&r1=304003&r2=304004&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Fri May 26 12:05:15 2017
@@ -1036,6 +1036,10 @@ void DwarfDebug::beginInstruction(const
   DebugHandlerBase::beginInstruction(MI);
   assert(CurMI);
 
+  const auto *SP = MI->getParent()->getParent()->getFunction()->getSubprogram();
+  if (!SP || SP->getUnit()->getEmissionKind() == DICompileUnit::NoDebug)
+    return;
+
   // Check if source location changes, but ignore DBG_VALUE and CFI locations.
   if (MI->isMetaInstruction())
     return;

Modified: llvm/trunk/test/DebugInfo/Generic/nodebug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/Generic/nodebug.ll?rev=304004&r1=304003&r2=304004&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/Generic/nodebug.ll (original)
+++ llvm/trunk/test/DebugInfo/Generic/nodebug.ll Fri May 26 12:05:15 2017
@@ -1,6 +1,6 @@
 ; REQUIRES: object-emission
 
-; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s
+; RUN: %llc_dwarf < %s -filetype=obj | llvm-dwarfdump - | FileCheck %s
 
 ; Test that a nodebug function (a function not appearing in the debug info IR
 ; metadata subprogram list) with DebugLocs on its IR doesn't cause crashes/does
@@ -17,9 +17,16 @@
 ; }
 
 ; Check that there's no DW_TAG_subprogram, not even for the 'f2' function.
+; CHECK: .debug_info contents:
 ; CHECK: DW_TAG_compile_unit
 ; CHECK-NOT: DW_TAG_subprogram
 
+; Expect no line table entry since there are no functions and file references in this compile unit
+; CHECK: .debug_line contents:
+; CHECK: Line table prologue:
+; CHECK: total_length: 0x00000019
+; CHECK-NOT: file_names[
+
 @i = external global i32
 
 ; Function Attrs: uwtable




More information about the llvm-commits mailing list