OSDN Git Service

Rename DeleteBlockIfDead to DeleteDeadBlock and make it
authorChris Lattner <sabre@nondot.org>
Wed, 3 Dec 2008 06:40:52 +0000 (06:40 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 3 Dec 2008 06:40:52 +0000 (06:40 +0000)
unconditionally delete the block.  All likely clients will
do the checking anyway.

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

include/llvm/Transforms/Utils/BasicBlockUtils.h
lib/Transforms/Utils/BasicBlockUtils.cpp
lib/Transforms/Utils/SimplifyCFG.cpp

index 881bcff..d6140ae 100644 (file)
@@ -26,10 +26,9 @@ class Instruction;
 class Pass;
 class AliasAnalysis;
 
-/// DeleteBlockIfDead - If the specified basic block is trivially dead (has no
-/// predecessors and not the entry block), delete it and return true.  Otherwise
-/// return false.
-bool DeleteBlockIfDead(BasicBlock *BB);
+/// DeleteDeadBlock - Delete the specified block, which must have no
+/// predecessors.
+void DeleteDeadBlock(BasicBlock *BB);
   
 /// MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor,
 /// if possible.  The return value indicates success or failure.
index bfcf375..9452e6e 100644 (file)
 #include <algorithm>
 using namespace llvm;
 
-/// DeleteBlockIfDead - If the specified basic block is trivially dead (has no
-/// predecessors and not the entry block), delete it and return true.  Otherwise
-/// return false.
-bool llvm::DeleteBlockIfDead(BasicBlock *BB) {
-  if (pred_begin(BB) != pred_end(BB) ||
-      BB == &BB->getParent()->getEntryBlock())
-    return false;
-  
+/// DeleteDeadBlock - Delete the specified block, which must have no
+/// predecessors.
+void llvm::DeleteDeadBlock(BasicBlock *BB) {
+  assert(pred_begin(BB) != pred_end(BB) && "Block is not dead!");
   TerminatorInst *BBTerm = BB->getTerminator();
   
   // Loop through all of our successors and make sure they know that one
@@ -54,7 +50,6 @@ bool llvm::DeleteBlockIfDead(BasicBlock *BB) {
   
   // Zap the block!
   BB->eraseFromParent();
-  return true;
 }
 
 /// MergeBlockIntoPredecessor - Attempts to merge a block into its predecessor,
index 7077436..f4faeb3 100644 (file)
@@ -1681,7 +1681,7 @@ bool llvm::SimplifyCFG(BasicBlock *BB) {
   // as a predecessor.  These are unreachable.
   if (pred_begin(BB) == pred_end(BB) || BB->getSinglePredecessor() == BB) {
     DOUT << "Removing BB: \n" << *BB;
-    DeleteBlockIfDead(BB);
+    DeleteDeadBlock(BB);
     return true;
   }