[llvm] 76fd78b - [MVerifier] Don't check liveness of any debug instruction operands

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 28 07:05:24 PST 2022


Author: Jeremy Morse
Date: 2022-01-28T15:04:54Z
New Revision: 76fd78b4b35a6831af0b37ab74764892231077eb

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

LOG: [MVerifier] Don't check liveness of any debug instruction operands

Shiny new DBG_PHI instruction usually have physical registers as operands
-- however, the machine verifier checks to see whether they're live, and
occasionally this fails. There's a filter for DBG_VALUE instructions to not
get verified in this way: expand it to exempt all debug instructions from
liveness checking, which means DBG_PHIs get treated like DBG_VALUEs.

This also future proofs against us adding new debug instructions.

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

Added: 
    llvm/test/DebugInfo/MIR/InstrRef/accept-nonlive-reg-phis.mir

Modified: 
    llvm/lib/CodeGen/MachineVerifier.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/MachineVerifier.cpp b/llvm/lib/CodeGen/MachineVerifier.cpp
index 005d4ad1a3280..c9d3e473062b1 100644
--- a/llvm/lib/CodeGen/MachineVerifier.cpp
+++ b/llvm/lib/CodeGen/MachineVerifier.cpp
@@ -1909,7 +1909,7 @@ MachineVerifier::visitMachineOperand(const MachineOperand *MO, unsigned MONum) {
     const Register Reg = MO->getReg();
     if (!Reg)
       return;
-    if (MRI->tracksLiveness() && !MI->isDebugValue())
+    if (MRI->tracksLiveness() && !MI->isDebugInstr())
       checkLiveness(MO, MONum);
 
     // Verify the consistency of tied operands.

diff  --git a/llvm/test/DebugInfo/MIR/InstrRef/accept-nonlive-reg-phis.mir b/llvm/test/DebugInfo/MIR/InstrRef/accept-nonlive-reg-phis.mir
new file mode 100644
index 0000000000000..016db912107c4
--- /dev/null
+++ b/llvm/test/DebugInfo/MIR/InstrRef/accept-nonlive-reg-phis.mir
@@ -0,0 +1,87 @@
+# RUN: llc %s -verify-machineinstrs -o - -run-pass=livedebugvalues \
+# RUN:      -experimental-debug-variable-locations=true | FileCheck %s
+#
+# Test that we don't explode in a verifier error when we have a DBG_PHI of
+# a physreg that is not live. Doesn't matter what variable locations are
+# created.
+#
+# CHECK-NOT: Found {{.*}} machine code errors
+# CHECK: DBG_PHI $fp0
+# CHECK-NOT: Found {{.*}} machine code errors
+
+--- |
+  target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+  target triple = "x86_64-unknown-linux"
+  
+  @b = dso_local local_unnamed_addr global i32 0, align 4, !dbg !0
+  @a = dso_local local_unnamed_addr global i32 0, align 4, !dbg !5
+  
+  define dso_local i32 @c() local_unnamed_addr !dbg !13 {
+  entry:
+    ret i32 0, !dbg !36
+  }
+  
+  declare void @llvm.dbg.declare(metadata, metadata, metadata)
+  
+  declare void @llvm.dbg.value(metadata, metadata, metadata)
+  
+  !llvm.dbg.cu = !{!2}
+  !llvm.module.flags = !{!8, !9, !10, !11}
+  !llvm.ident = !{!12}
+  
+  !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+  !1 = distinct !DIGlobalVariable(name: "b", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)
+  !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 14.0.0 (git at github.com:llvm/llvm-project 1b09d0c42b42be219dd0984e0714d68b4a36cd3e)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+  !3 = !DIFile(filename: "bbi-65026.c", directory: "/tmp")
+  !4 = !{!5, !0}
+  !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+  !6 = distinct !DIGlobalVariable(name: "a", scope: !2, file: !3, line: 1, type: !7, isLocal: false, isDefinition: true)
+  !7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+  !8 = !{i32 7, !"Dwarf Version", i32 4}
+  !9 = !{i32 2, !"Debug Info Version", i32 3}
+  !10 = !{i32 1, !"wchar_size", i32 4}
+  !11 = !{i32 7, !"uwtable", i32 1}
+  !12 = !{!"clang version 14.0.0 (git at github.com:llvm/llvm-project 1b09d0c42b42be219dd0984e0714d68b4a36cd3e)"}
+  !13 = distinct !DISubprogram(name: "c", scope: !3, file: !3, line: 2, type: !14, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !16)
+  !14 = !DISubroutineType(types: !15)
+  !15 = !{!7}
+  !16 = !{!17}
+  !17 = !DILocalVariable(name: "d", scope: !13, file: !3, line: 3, type: !18)
+  !18 = !DIBasicType(name: "long double", size: 128, encoding: DW_ATE_float)
+  !19 = !DILocation(line: 3, column: 15, scope: !13)
+  !20 = !DILocation(line: 4, column: 7, scope: !21)
+  !21 = distinct !DILexicalBlock(scope: !13, file: !3, line: 4, column: 7)
+  !22 = !{!23, !23, i64 0}
+  !23 = !{!"int", !24, i64 0}
+  !24 = !{!"omnipotent char", !25, i64 0}
+  !25 = !{!"Simple C/C++ TBAA"}
+  !26 = !DILocation(line: 4, column: 9, scope: !21)
+  !27 = !DILocation(line: 0, scope: !21)
+  !28 = !DILocation(line: 4, column: 7, scope: !13)
+  !29 = !DILocation(line: 5, column: 9, scope: !21)
+  !30 = !DILocation(line: 0, scope: !13)
+  !31 = !DILocation(line: 5, column: 5, scope: !21)
+  !32 = !DILocation(line: 7, column: 11, scope: !21)
+  !33 = !DILocation(line: 7, column: 9, scope: !21)
+  !34 = !DILocation(line: 7, column: 15, scope: !21)
+  !35 = !DILocation(line: 8, column: 10, scope: !13)
+  !36 = !DILocation(line: 8, column: 3, scope: !13)
+
+...
+---
+name:            c
+alignment:       16
+tracksRegLiveness: true
+tracksDebugUserValues: true
+frameInfo:
+  maxAlignment:    4
+machineFunctionInfo: {}
+body:             |
+  bb.0.entry:
+  
+    DBG_PHI $fp0, 3
+    DBG_INSTR_REF 3, 0, !17, !DIExpression(), debug-location !30
+    $eax = MOV32ri 0
+    RET 0, debug-location !36
+
+...


        


More information about the llvm-commits mailing list