[PATCH] D27492: [DWARF] Suppress .loc directives coming from CFI instructions

Paul Robinson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 16:45:25 PST 2016


probinson created this revision.
probinson added reviewers: dblaikie, aprantl.
probinson added subscribers: llvm-commits, kcc.

CFI pseudo-instructions emit nothing to the .text section, therefore there's no reason to emit their source locations into the line table.
In practice, a CFI instruction's source location will be one of three things: (a) exactly the same as the preceding instruction; (b) exactly the same as the following instruction; (c) unspecified.  The first two cases have no net effect on the line table.  The third case will emit a "line 0" record whenever we turn unspecified locations into "line 0" which can happen with `-use-unknown-locations` or, after the patch in https://reviews.llvm.org/D24180 lands (again), if the CFI instruction happens to be at the top of a basic block.  This patch causes the third case to have no net effect on the line table, just like the other cases.


https://reviews.llvm.org/D27492

Files:
  lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  test/DebugInfo/Generic/no-cfi-loc.ll


Index: test/DebugInfo/Generic/no-cfi-loc.ll
===================================================================
--- test/DebugInfo/Generic/no-cfi-loc.ll
+++ test/DebugInfo/Generic/no-cfi-loc.ll
@@ -0,0 +1,25 @@
+; RUN: %llc_dwarf -filetype=asm -use-unknown-locations < %s | FileCheck %s
+; CHECK-NOT: .loc 1 0 0
+
+define void @foo() !dbg !6 {
+entry:
+  call void @bar(), !dbg !8
+  ret void, !dbg !9
+}
+
+declare void @bar()
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+!llvm.ident = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 288778)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
+!1 = !DIFile(filename: "t.c", directory: "/home/probinson/projects/scratch")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{!"clang version 4.0.0 (trunk 288778)"}
+!6 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 2, type: !7, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!7 = !DISubroutineType(types: !2)
+!8 = !DILocation(line: 3, column: 2, scope: !6)
+!9 = !DILocation(line: 4, column: 1, scope: !6)
Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===================================================================
--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1006,8 +1006,8 @@
   DebugHandlerBase::beginInstruction(MI);
   assert(CurMI);
 
-  // Check if source location changes, but ignore DBG_VALUE locations.
-  if (MI->isDebugValue())
+  // Check if source location changes, but ignore DBG_VALUE and CFI locations.
+  if (MI->isDebugValue() || MI->isCFIInstruction())
     return;
   const DebugLoc &DL = MI->getDebugLoc();
   if (DL == PrevInstLoc)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27492.80503.patch
Type: text/x-patch
Size: 1849 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161207/0be660cc/attachment.bin>


More information about the llvm-commits mailing list