]> granicus.if.org Git - llvm/commitdiff
DebugInfo: Don't include locations for debug-having code inlined into nodebug functions
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 26 May 2017 17:05:15 +0000 (17:05 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 26 May 2017 17:05:15 +0000 (17:05 +0000)
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)

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

lib/CodeGen/AsmPrinter/DwarfDebug.cpp
test/DebugInfo/Generic/nodebug.ll

index b696312fd28e798112c67cc724911d3cc76b2639..3ea4c1c2775c2b5e316cd7b683e594cec3f87114 100644 (file)
@@ -1036,6 +1036,10 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
   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;
index f85b00bf9f7eefbcdc3f58058a3c1b76814d164c..93ed49d5417aebc3df5b3f90fe6fd869920ca3cd 100644 (file)
@@ -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
 ; }
 
 ; 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