[llvm-branch-commits] [llvm-branch] r115218 - in /llvm/branches/Apple/whitney: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/crash.ll

Daniel Dunbar daniel at zuster.org
Thu Sep 30 15:19:18 PDT 2010


Author: ddunbar
Date: Thu Sep 30 17:19:18 2010
New Revision: 115218

URL: http://llvm.org/viewvc/llvm-project?rev=115218&view=rev
Log:
Merge r115082:
--
Author: Owen Anderson <owen at apple.com>
Date:   Wed Sep 29 20:34:41 2010 +0000

    Fix PR8247: JumpThreading can cause a block to become unreachable while still having predecessor, if it is part of a self-loop.
    Because of this, we cannot use the Simplify* APIs, as they can assert-fail on unreachable code.  Since it's not easy to determine
    if a given threading will cause a block to become unreachable, simply defer simplifying simplification to later InstCombine and/or
    DCE passes.

Modified:
    llvm/branches/Apple/whitney/lib/Transforms/Scalar/JumpThreading.cpp
    llvm/branches/Apple/whitney/test/Transforms/JumpThreading/crash.ll

Modified: llvm/branches/Apple/whitney/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/lib/Transforms/Scalar/JumpThreading.cpp?rev=115218&r1=115217&r2=115218&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/branches/Apple/whitney/lib/Transforms/Scalar/JumpThreading.cpp Thu Sep 30 17:19:18 2010
@@ -613,7 +613,7 @@
     TerminatorInst *BBTerm = BB->getTerminator();
     for (unsigned i = 0, e = BBTerm->getNumSuccessors(); i != e; ++i) {
       if (i == BestSucc) continue;
-      RemovePredecessorAndSimplify(BBTerm->getSuccessor(i), BB, TD);
+      BBTerm->getSuccessor(i)->removePredecessor(BB, true);
     }
     
     DEBUG(dbgs() << "  In block '" << BB->getName()
@@ -664,7 +664,7 @@
         if (PI == PE) {
           unsigned ToRemove = Baseline == LazyValueInfo::True ? 1 : 0;
           unsigned ToKeep = Baseline == LazyValueInfo::True ? 0 : 1;
-          RemovePredecessorAndSimplify(CondBr->getSuccessor(ToRemove), BB, TD);
+          CondBr->getSuccessor(ToRemove)->removePredecessor(BB, true);
           BranchInst::Create(CondBr->getSuccessor(ToKeep), CondBr);
           CondBr->eraseFromParent();
           return true;
@@ -1470,7 +1470,7 @@
   TerminatorInst *PredTerm = PredBB->getTerminator();
   for (unsigned i = 0, e = PredTerm->getNumSuccessors(); i != e; ++i)
     if (PredTerm->getSuccessor(i) == BB) {
-      RemovePredecessorAndSimplify(BB, PredBB, TD);
+      BB->removePredecessor(PredBB, true);
       PredTerm->setSuccessor(i, NewBB);
     }
   
@@ -1620,7 +1620,7 @@
   
   // PredBB no longer jumps to BB, remove entries in the PHI node for the edge
   // that we nuked.
-  RemovePredecessorAndSimplify(BB, PredBB, TD);
+  BB->removePredecessor(PredBB, true);
   
   // Remove the unconditional branch at the end of the PredBB block.
   OldPredBranch->eraseFromParent();

Modified: llvm/branches/Apple/whitney/test/Transforms/JumpThreading/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/test/Transforms/JumpThreading/crash.ll?rev=115218&r1=115217&r2=115218&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/test/Transforms/JumpThreading/crash.ll (original)
+++ llvm/branches/Apple/whitney/test/Transforms/JumpThreading/crash.ll Thu Sep 30 17:19:18 2010
@@ -484,3 +484,30 @@
 bb288.bb289.loopexit_crit_edge:
   unreachable
 }
+
+; PR 8247
+%struct.S1 = type { i8, i8 }
+ at func_89.l_245 = internal constant %struct.S1 { i8 33, i8 6 }, align 1
+define void @func_89(i16 zeroext %p_90, %struct.S1* nocapture %p_91, i32* nocapture %p_92) nounwind ssp {
+entry:
+  store i32 0, i32* %p_92, align 4
+  br i1 false, label %lbl_260, label %if.else
+
+if.else:                                          ; preds = %entry
+  br label %for.cond
+
+for.cond:                                         ; preds = %lbl_260, %if.else
+  %l_245.0 = phi i16 [ %l_245.1, %lbl_260 ], [ 33, %if.else ]
+  %l_261.0 = phi i32 [ %and, %lbl_260 ], [ 255, %if.else ]
+  %tobool21 = icmp ult i16 %l_245.0, 256
+  br i1 %tobool21, label %if.end, label %lbl_260
+
+lbl_260:                                          ; preds = %for.cond, %entry
+  %l_245.1 = phi i16 [ 1569, %entry ], [ %l_245.0, %for.cond ]
+  %l_261.1 = phi i32 [ 255, %entry ], [ %l_261.0, %for.cond ]
+  %and = and i32 %l_261.1, 1
+  br label %for.cond
+
+if.end:                                           ; preds = %for.cond
+  ret void
+}





More information about the llvm-branch-commits mailing list