simplify this code a bit.
authorChris Lattner <sabre@nondot.org>
Thu, 27 Nov 2008 07:54:38 +0000 (07:54 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 27 Nov 2008 07:54:38 +0000 (07:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60164 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index 596c5643e544369ba9731aa3895c0749606ceced..5c2f51442a1ad61942d16bdced96ddab0ef77306 100644 (file)
@@ -1709,9 +1709,9 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
   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 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
       // Remove the instruction from the basic block
       BB->getInstList().pop_back();
     }
-    M->getBasicBlockList().erase(BB);
+    BB->eraseFromParent();
     return true;
   }