[llvm-commits] [llvm] r86723 - /llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp

Chris Lattner sabre at nondot.org
Tue Nov 10 13:45:09 PST 2009


Author: lattner
Date: Tue Nov 10 15:45:09 2009
New Revision: 86723

URL: http://llvm.org/viewvc/llvm-project?rev=86723&view=rev
Log:
improve comment.

Modified:
    llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=86723&r1=86722&r2=86723&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Tue Nov 10 15:45:09 2009
@@ -142,11 +142,14 @@
             ++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);
           }
         }





More information about the llvm-commits mailing list