improve comment.
authorChris Lattner <sabre@nondot.org>
Tue, 10 Nov 2009 21:45:09 +0000 (21:45 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 10 Nov 2009 21:45:09 +0000 (21:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86723 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/JumpThreading.cpp

index 1d89399e7411b9d74f9d26e735ac64039feb7107..2d8309d520284e724bc0e89b02ec99afde90ea6e 100644 (file)
@@ -142,11 +142,14 @@ bool JumpThreading::runOnFunction(Function &F) {
             ++BBI;
           // If the terminator is the only non-phi instruction, try to nuke it.
           if (BBI->isTerminator()) {
-            bool Erased = LoopHeaders.erase(BB);
+            // Since TryToSimplifyUncondBranchFromEmptyBlock may delete the
+            // block, we have to make sure it isn't in the LoopHeaders set.  We
+            // reinsert afterward in the rare case when the block isn't deleted.
+            bool ErasedFromLoopHeaders = LoopHeaders.erase(BB);
             
             if (TryToSimplifyUncondBranchFromEmptyBlock(BB))
               Changed = true;
-            else if (Erased)
+            else if (ErasedFromLoopHeaders)
               LoopHeaders.insert(BB);
           }
         }