fix a bug I introduced in simplifycfg handling single entry phi
authorChris Lattner <sabre@nondot.org>
Sun, 7 Dec 2008 07:22:45 +0000 (07:22 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 7 Dec 2008 07:22:45 +0000 (07:22 +0000)
nodes. FoldSingleEntryPHINodes deletes the PHI, so there is no
need to delete it afterward.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60653 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll [new file with mode: 0644]

index d6465f599cf4726b565258bb3c7dd5c2520200d9..e7bd75e04931084b43f8e1400d76f2d2b5db4813 100644 (file)
@@ -1102,7 +1102,6 @@ static bool FoldCondBranchOnPHI(BranchInst *BI) {
   // Degenerate case of a single entry PHI.
   if (PN->getNumIncomingValues() == 1) {
     FoldSingleEntryPHINodes(PN->getParent());
-    PN->eraseFromParent();
     return true;    
   }
 
diff --git a/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll b/test/Transforms/SimplifyCFG/2008-12-06-SingleEntryPhi.ll
new file mode 100644 (file)
index 0000000..7b4aee4
--- /dev/null
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis
+define i32 @test() {
+entry:
+       br label %T
+T:
+       %C = phi i1 [false, %entry] 
+       br i1 %C, label %X, label %Y
+X:
+       ret i32 2
+Y:
+       add i32 1, 2
+       ret i32 1
+}