[llvm] 01c90bb - [Transforms][Debugify] Fix "Missing line" false alarm on PHI nodes

Djordje Todorovic via llvm-commits llvm-commits at lists.llvm.org
Fri May 14 05:06:32 PDT 2021


Author: Djordje Todorovic
Date: 2021-05-14T14:06:13+02:00
New Revision: 01c90bbd4fd12aa86db4a47577addb47e6e84289

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

LOG: [Transforms][Debugify] Fix "Missing line" false alarm on PHI nodes

This is a fix for https://bugs.llvm.org/show_bug.cgi?id=49959

The "Missing line" false alarm was introduced in D75242.

Patch by Yilong Guo<yilong.guo at intel.com>

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

Added: 
    llvm/test/DebugInfo/debugify-ignore-phi.ll

Modified: 
    llvm/lib/Transforms/Utils/Debugify.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index 413981b561fd0..cbea40773a0a2 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -623,7 +623,7 @@ bool checkDebugifyMetadata(Module &M,
 
     // Find missing lines.
     for (Instruction &I : instructions(F)) {
-      if (isa<DbgValueInst>(&I) || isa<PHINode>(&I))
+      if (isa<DbgValueInst>(&I))
         continue;
 
       auto DL = I.getDebugLoc();
@@ -632,7 +632,7 @@ bool checkDebugifyMetadata(Module &M,
         continue;
       }
 
-      if (!DL) {
+      if (!isa<PHINode>(&I) && !DL) {
         dbg() << "WARNING: Instruction with empty DebugLoc in function ";
         dbg() << F.getName() << " --";
         I.print(dbg());

diff  --git a/llvm/test/DebugInfo/debugify-ignore-phi.ll b/llvm/test/DebugInfo/debugify-ignore-phi.ll
new file mode 100644
index 0000000000000..bae91e4e52cb8
--- /dev/null
+++ b/llvm/test/DebugInfo/debugify-ignore-phi.ll
@@ -0,0 +1,38 @@
+; RUN: opt -check-debugify < %s -S 2>&1 | FileCheck %s
+
+define void @test_phi(i1 %cond) !dbg !6 {
+  br i1 %cond, label %1, label %2, !dbg !11
+
+1:                                                ; preds = %0
+  br label %2, !dbg !12
+
+2:                                                ; preds = %1, %0
+  %v = phi i32 [ 0, %0 ], [ 1, %1 ], !dbg !13
+  call void @llvm.dbg.value(metadata i32 %v, metadata !9, metadata !DIExpression()), !dbg !13
+  ret void, !dbg !14
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!3, !4}
+!llvm.module.flags = !{!5}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "<stdin>", directory: "/")
+!2 = !{}
+!3 = !{i32 4}
+!4 = !{i32 1}
+!5 = !{i32 2, !"Debug Info Version", i32 3}
+!6 = distinct !DISubprogram(name: "test_phi", linkageName: "test_phi", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
+!7 = !DISubroutineType(types: !2)
+!8 = !{!9}
+!9 = !DILocalVariable(name: "1", scope: !6, file: !1, line: 3, type: !10)
+!10 = !DIBasicType(name: "ty32", size: 32, encoding: DW_ATE_unsigned)
+!11 = !DILocation(line: 1, column: 1, scope: !6)
+!12 = !DILocation(line: 2, column: 1, scope: !6)
+!13 = !DILocation(line: 3, column: 1, scope: !6)
+!14 = !DILocation(line: 4, column: 1, scope: !6)
+
+; CHECK-NOT: WARNING: Missing line 3
+; CHECK: CheckModuleDebugify: PASS


        


More information about the llvm-commits mailing list