[llvm-commits] [llvm] r60164 - /llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Chris Lattner sabre at nondot.org
Wed Nov 26 23:54:38 PST 2008


Author: lattner
Date: Thu Nov 27 01:54:38 2008
New Revision: 60164

URL: http://llvm.org/viewvc/llvm-project?rev=60164&view=rev
Log:
simplify this code a bit.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=60164&r1=60163&r2=60164&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Thu Nov 27 01:54:38 2008
@@ -1709,9 +1709,9 @@
   assert(&BB->getParent()->getEntryBlock() != BB &&
          "Can't Simplify entry block!");
 
-  // Remove basic blocks that have no predecessors... which are unreachable.
-  if ((pred_begin(BB) == pred_end(BB)) ||
-      (*pred_begin(BB) == BB && ++pred_begin(BB) == pred_end(BB))) {
+  // Remove basic blocks that have no predecessors... or that just have themself
+  // as a predecessor.  These are unreachable.
+  if (pred_begin(BB) == pred_end(BB) || BB->getSinglePredecessor() == BB) {
     DOUT << "Removing BB: \n" << *BB;
 
     // Loop through all of our successors and make sure they know that one
@@ -1733,7 +1733,7 @@
       // Remove the instruction from the basic block
       BB->getInstList().pop_back();
     }
-    M->getBasicBlockList().erase(BB);
+    BB->eraseFromParent();
     return true;
   }
 





More information about the llvm-commits mailing list