* Standardize how analysis results/passes as printed with the print() virtual
[oota-llvm.git] / lib / Transforms / Scalar / ADCE.cpp
index 237c4589b2a8b8d42d2a7fffd81536a22c937c8d..06301971f73faaf618646cd6bfd1306a41fea18d 100644 (file)
@@ -10,7 +10,6 @@
 #include "llvm/Transforms/Utils/Local.h"
 #include "llvm/Type.h"
 #include "llvm/Analysis/Dominators.h"
-#include "llvm/Analysis/Writer.h"
 #include "llvm/iTerminators.h"
 #include "llvm/iPHINode.h"
 #include "llvm/Constant.h"
@@ -21,6 +20,7 @@
 #include <algorithm>
 #include <iostream>
 using std::cerr;
+using std::vector;
 
 static Statistic<> NumBlockRemoved("adce\t\t- Number of basic blocks removed");
 static Statistic<> NumInstRemoved ("adce\t\t- Number of instructions removed");
@@ -42,8 +42,6 @@ class ADCE : public FunctionPass {
   // The public interface for this class
   //
 public:
-  const char *getPassName() const { return "Aggressive Dead Code Elimination"; }
-  
   // Execute the Aggressive Dead Code Elimination Algorithm
   //
   virtual bool runOnFunction(Function &F) {
@@ -56,8 +54,8 @@ public:
   // getAnalysisUsage - We require post dominance frontiers (aka Control
   // Dependence Graph)
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-    AU.addRequired(DominatorTree::PostDomID);
-    AU.addRequired(DominanceFrontier::PostDomID);
+    AU.addRequired(PostDominatorTree::ID);
+    AU.addRequired(PostDominanceFrontier::ID);
   }
 
 
@@ -85,22 +83,21 @@ private:
   }
 };
 
+  RegisterOpt<ADCE> X("adce", "Aggressive Dead Code Elimination");
 } // End of anonymous namespace
 
 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...
   //
-  DominanceFrontier &CDG =
-    getAnalysis<DominanceFrontier>(DominanceFrontier::PostDomID);
+  PostDominanceFrontier &CDG = getAnalysis<PostDominanceFrontier>();
 
-  DominanceFrontier::const_iterator It = CDG.find(BB);
+  PostDominanceFrontier::const_iterator It = CDG.find(BB);
   if (It != CDG.end()) {
     // Get the blocks that this node is control dependant on...
-    const DominanceFrontier::DomSetType &CDB = It->second;
+    const PostDominanceFrontier::DomSetType &CDB = It->second;
     for_each(CDB.begin(), CDB.end(),   // Mark all their terminators as live
              bind_obj(this, &ADCE::markTerminatorLive));
   }
@@ -192,7 +189,7 @@ bool ADCE::doADCE() {
   // Find the first postdominator of the entry node that is alive.  Make it the
   // new entry node...
   //
-  DominatorTree &DT = getAnalysis<DominatorTree>(DominatorTree::PostDomID);
+  PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
 
   // If there are some blocks dead...
   if (AliveBlocks.size() != Func->size()) {
@@ -219,8 +216,8 @@ bool ADCE::doADCE() {
             // postdominator that is alive, and the last postdominator that is
             // dead...
             //
-            DominatorTree::Node *LastNode = DT[TI->getSuccessor(i)];
-            DominatorTree::Node *NextNode = LastNode->getIDom();
+            PostDominatorTree::Node *LastNode = DT[TI->getSuccessor(i)];
+            PostDominatorTree::Node *NextNode = LastNode->getIDom();
             while (!AliveBlocks.count(NextNode->getNode())) {
               LastNode = NextNode;
               NextNode = NextNode->getIDom();