[llvm] f514776 - [DebugInfo][LiveDebugValues] Teach Live Debug Values About Meta Instructions

Tom Weaver via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 08:29:30 PST 2020


Author: Tom Weaver
Date: 2020-01-24T16:29:05Z
New Revision: f5147765ba170b4809dc72d34359be3355d48de8

URL: https://github.com/llvm/llvm-project/commit/f5147765ba170b4809dc72d34359be3355d48de8
DIFF: https://github.com/llvm/llvm-project/commit/f5147765ba170b4809dc72d34359be3355d48de8.diff

LOG: [DebugInfo][LiveDebugValues] Teach Live Debug Values About Meta Instructions

Previously LiveDebugValues pass would consider meta instructions that 'fiddle' with liveness of registers as register definitions when transfering register defs. This would mean that, for example, a KILL instruction would cause LiveDebugValues to terminate the range of an earlier DBG_VALUE instruction resulting in the none propogation of said DBG_VALUE instructions into later blocks.

This patch adds the check and a helpful comment, fixes a test that previously tested for the broken behaviour by coincidence and adds a test specifically for this.

reviewers: vsk, dstenb, djtodoro

Differential Revision: https://reviews.llvm.org/D73210

Added: 
    llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir

Modified: 
    llvm/lib/CodeGen/LiveDebugValues.cpp
    llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues.cpp
index 2226c10b49a4..6acaf4099c3e 100644
--- a/llvm/lib/CodeGen/LiveDebugValues.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues.cpp
@@ -922,6 +922,12 @@ void LiveDebugValues::insertTransferDebugPair(
 void LiveDebugValues::transferRegisterDef(
     MachineInstr &MI, OpenRangesSet &OpenRanges, VarLocMap &VarLocIDs,
     TransferMap &Transfers) {
+
+  // Meta Instructions do not affect the debug liveness of any register they
+  // define.
+  if (MI.isMetaInstruction())
+    return;
+
   MachineFunction *MF = MI.getMF();
   const TargetLowering *TLI = MF->getSubtarget().getTargetLowering();
   unsigned SP = TLI->getStackPointerRegisterToSaveRestore();

diff  --git a/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir b/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
index 8d121c3a30b9..adc43d96a961 100644
--- a/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
+++ b/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
@@ -19,7 +19,6 @@
 # CHECK: ![[ARG_A:.*]] = !DILocalVariable(name: "a"
 # CHECK: ![[ARG_B:.*]] = !DILocalVariable(name: "b"
 # CHECK: ![[ARG_C:.*]] = !DILocalVariable(name: "c"
-# CHECK: DBG_VALUE $edi, $noreg, ![[ARG_A]], !DIExpression(DW_OP_LLVM_entry_value, 1)
 # CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1)
 # CHECK: DBG_VALUE $edi, $noreg, ![[ARG_A]], !DIExpression(DW_OP_LLVM_entry_value, 1)
 # CHECK-NOT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1)

diff  --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir
new file mode 100644
index 000000000000..e8c3a994e59d
--- /dev/null
+++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir
@@ -0,0 +1,64 @@
+--- |
+  ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE
+
+  ; Check that live-debug-values ignores meta instructions.
+
+  ; CHECK-LABEL: bb.0.entry:
+  ; CHECK:       DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
+  ; CHECK-LABEL: bb.1.bb1:
+  ; CHECK:       DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
+  ; CHECK-LABEL: bb.2.bb2:
+  ; CHECK:       DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
+  ; CHECK-LABEL: bb.3.bb3:
+  ; CHECK:       DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
+
+  define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 {
+  entry:
+    br label %bb1, !dbg !17
+  bb1:
+    br label %bb2, !dbg !17
+  bb2:
+    br label %bb3, !dbg !17
+  bb3:
+    ret i32 0, !dbg !17
+  }
+
+  !llvm.dbg.cu = !{!0}
+  !llvm.module.flags = !{!7, !8, !9, !10}
+  !llvm.ident = !{!11}
+  !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None)
+  !1 = !DIFile(filename: "main.cpp", directory: "F:\")
+  !2 = !{}
+  !3 = !{!4}
+  !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression())
+  !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true)
+  !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+  !7 = !{i32 2, !"Dwarf Version", i32 4}
+  !8 = !{i32 2, !"Debug Info Version", i32 3}
+  !9 = !{i32 1, !"wchar_size", i32 2}
+  !10 = !{i32 7, !"PIC Level", i32 2}
+  !11 = !{!"clang version 10.0.0"}
+  !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15)
+  !13 = !DISubroutineType(types: !14)
+  !14 = !{!6, !6}
+  !15 = !{!16}
+  !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6)
+  !17 = !DILocation(line: 10, scope: !12)
+
+...
+---
+name:            _Z8bb_to_bb
+body:             |
+  bb.0.entry:
+    successors: %bb.1
+    $ebx = MOV32ri 0, debug-location !17
+    DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17
+  bb.1.bb1:
+    successors: %bb.2
+    renamable $ebx = KILL $ebx
+  bb.2.bb2:
+    successors: %bb.3
+    renamable $ebx = KILL $ebx
+  bb.3.bb3:
+    RETQ $eax, debug-location !17
+...


        


More information about the llvm-commits mailing list