[PATCH] D18443: [Verifier] Reject PHIs using definitions from own block.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Sat Mar 26 01:16:35 PDT 2016


Meinersbur updated the summary for this revision.
Meinersbur removed rL LLVM as the repository for this revision.
Meinersbur updated this revision to Diff 51711.
Meinersbur added a comment.

Restructured InstsInThisBlock as early exit; Reinserted the test case for PR15384 as it was probably just a typo.


http://reviews.llvm.org/D18443

Files:
  lib/IR/Verifier.cpp
  test/Transforms/LoopVectorize/phi-hang.ll
  test/Verifier/dominates.ll

Index: test/Verifier/dominates.ll
===================================================================
--- test/Verifier/dominates.ll
+++ test/Verifier/dominates.ll
@@ -55,3 +55,16 @@
 ; CHECK-NEXT:  %y1 = add i32 %x, 1
 ; CHECK-NEXT:  %y3 = phi i32 [ %y1, %bb0 ]
 }
+
+define void @f5() {
+entry:
+  br label %next
+
+next:
+  %y = phi i32 [ 0, %entry ]
+  %x = phi i32 [ %y, %entry ]
+  ret void
+; CHECK: Instruction does not dominate all uses!
+; CHECK-NEXT:  %y = phi i32 [ 0, %entry ]
+; CHECK-NEXT:  %x = phi i32 [ %y, %entry ]
+}
Index: test/Transforms/LoopVectorize/phi-hang.ll
===================================================================
--- test/Transforms/LoopVectorize/phi-hang.ll
+++ test/Transforms/LoopVectorize/phi-hang.ll
@@ -18,7 +18,7 @@
 
 bb5:                                              ; preds = %bb4, %bb1
   %tmp6 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ]
-  %tmp7 = phi i32 [ 0, %bb4 ], [ %tmp6, %bb1 ]
+  %tmp7 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ]
   %tmp8 = phi i32 [ 0, %bb4 ], [ %tmp, %bb1 ]
   %tmp9 = add nsw i32 %tmp2, 1
   %tmp10 = icmp eq i32 %tmp9, 0
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -3397,8 +3397,14 @@
       return;
   }
 
+  // Quick check whether the def has already been encountered in the same block,
+  // unless it is a PHI node that never can use defs from its own block
+  // (eg. other PHIs)
+  if (!isa<PHINode>(I) && InstsInThisBlock.count(Op))
+    return;
+
   const Use &U = I.getOperandUse(i);
-  Assert(InstsInThisBlock.count(Op) || DT.dominates(Op, U),
+  Assert(DT.dominates(Op, U),
          "Instruction does not dominate all uses!", Op, &I);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18443.51711.patch
Type: text/x-patch
Size: 1725 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160326/e730695a/attachment.bin>


More information about the llvm-commits mailing list