Rename Function::getEntryNode -> getEntryBlock
[oota-llvm.git] / lib / Transforms / Scalar / ADCE.cpp
index 6b838ba1862d212769c675a63c39ede44128ce8b..8d71605406095aecbb8223afafd87c19c6bc0c20 100644 (file)
 #include "llvm/iPHINode.h"
 #include "llvm/Constant.h"
 #include "llvm/Support/CFG.h"
-#include "Support/STLExtras.h"
+#include "Support/Debug.h"
 #include "Support/DepthFirstIterator.h"
 #include "Support/Statistic.h"
+#include "Support/STLExtras.h"
 #include <algorithm>
 
 namespace {
@@ -83,8 +84,8 @@ private:
   }
 
   inline void markTerminatorLive(const BasicBlock *BB) {
-    DEBUG(std::cerr << "Terminat Live: " << BB->getTerminator());
-    markInstructionLive((Instruction*)BB->getTerminator());
+    DEBUG(std::cerr << "Terminator Live: " << BB->getTerminator());
+    markInstructionLive(const_cast<TerminatorInst*>(BB->getTerminator()));
   }
 };
 
@@ -95,13 +96,13 @@ Pass *createAggressiveDCEPass() { return new ADCE(); }
 
 void ADCE::markBlockAlive(BasicBlock *BB) {
   // Mark the basic block as being newly ALIVE... and mark all branches that
-  // this block is control dependant on as being alive also...
+  // this block is control dependent on as being alive also...
   //
   PostDominanceFrontier &CDG = getAnalysis<PostDominanceFrontier>();
 
   PostDominanceFrontier::const_iterator It = CDG.find(BB);
   if (It != CDG.end()) {
-    // Get the blocks that this node is control dependant on...
+    // Get the blocks that this node is control dependent on...
     const PostDominanceFrontier::DomSetType &CDB = It->second;
     for_each(CDB.begin(), CDB.end(),   // Mark all their terminators as live
              bind_obj(this, &ADCE::markTerminatorLive));
@@ -175,7 +176,7 @@ bool ADCE::doADCE() {
        BBI != BBE; ++BBI) {
     BasicBlock *BB = *BBI;
     for (BasicBlock::iterator II = BB->begin(), EI = BB->end(); II != EI; ) {
-      if (II->mayWriteToMemory() || II->getOpcode() == Instruction::Ret) {
+      if (II->mayWriteToMemory() || isa<ReturnInst>(II) || isa<UnwindInst>(II)){
        markInstructionLive(II);
         ++II;  // Increment the inst iterator if the inst wasn't deleted
       } else if (isInstructionTriviallyDead(II)) {
@@ -194,7 +195,7 @@ bool ADCE::doADCE() {
   // transformations safely.
   //
   PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
-  if (DT[&Func->getEntryNode()] == 0) {
+  if (DT[&Func->getEntryBlock()] == 0) {
     WorkList.clear();
     return MadeChanges;
   }
@@ -207,7 +208,7 @@ bool ADCE::doADCE() {
   std::set<BasicBlock*> AliveBlocks;
 
   // Process the work list of instructions that just became live... if they
-  // became live, then that means that all of their operands are neccesary as
+  // became live, then that means that all of their operands are necessary as
   // well... make them live as well.
   //
   while (!WorkList.empty()) {
@@ -343,14 +344,14 @@ bool ADCE::doADCE() {
             } else {
               PostDominatorTree::Node *NextNode = LastNode->getIDom();
 
-              while (!AliveBlocks.count(NextNode->getNode())) {
+              while (!AliveBlocks.count(NextNode->getBlock())) {
                 LastNode = NextNode;
                 NextNode = NextNode->getIDom();
               }
             
               // Get the basic blocks that we need...
-              BasicBlock *LastDead = LastNode->getNode();
-              BasicBlock *NextAlive = NextNode->getNode();
+              BasicBlock *LastDead = LastNode->getBlock();
+              BasicBlock *NextAlive = NextNode->getBlock();
 
               // Make the conditional branch now go to the next alive block...
               TI->getSuccessor(i)->removePredecessor(BB);