Fix infinite loop in DSE when deleting a free in a reachable loop that's also
authorNick Lewycky <nicholas@mxc.ca>
Thu, 8 Dec 2011 22:36:35 +0000 (22:36 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Thu, 8 Dec 2011 22:36:35 +0000 (22:36 +0000)
trivially infinite.

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

lib/Transforms/Scalar/DeadStoreElimination.cpp
test/Transforms/DeadStoreElimination/free.ll

index b9b1cc86c2965255a8760d779c2deca1f65a9340..8729019705f12bbd5589a2c018415f870d5ca89b 100644 (file)
@@ -624,6 +624,7 @@ static void FindUnconditionalPreds(SmallVectorImpl<BasicBlock *> &Blocks,
                                    BasicBlock *BB, DominatorTree *DT) {
   for (pred_iterator I = pred_begin(BB), E = pred_end(BB); I != E; ++I) {
     BasicBlock *Pred = *I;
+    if (Pred == BB) continue;
     TerminatorInst *PredTI = Pred->getTerminator();
     if (PredTI->getNumSuccessors() != 1)
       continue;
@@ -853,4 +854,3 @@ void DSE::RemoveAccessedObjects(const AliasAnalysis::Location &LoadedLoc,
        I != E; ++I)
     DeadStackObjects.erase(*I);
 }
-
index 168bd95e5392e837636219e63f89776046b86ac8..a5fbdc76387ea377e07dd329dcb50697c840b939 100644 (file)
@@ -58,3 +58,13 @@ skipinit1:
   tail call void @free(i8* %alloc1) nounwind
   ret void
 }
+
+; CHECK: @test5
+define void @test5() {
+  br label %bb
+
+bb:
+  tail call void @free(i8* undef) nounwind
+  br label %bb
+}
+