Break DominatorTree from ETNode.
authorDevang Patel <dpatel@apple.com>
Tue, 12 Jun 2007 00:54:38 +0000 (00:54 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 12 Jun 2007 00:54:38 +0000 (00:54 +0000)
Remove unused PostETForest.

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

include/llvm/Analysis/Dominators.h
include/llvm/Analysis/PostDominators.h
lib/Analysis/PostDominators.cpp
lib/VMCore/Dominators.cpp

index f2d6da53e1e99e46d3c95caeac1b00b802300a18..34d027d03b07396a47e9cc646317dc9208dee3be 100644 (file)
@@ -63,7 +63,6 @@ public:
 class DomTreeNode {
   BasicBlock *TheBB;
   DomTreeNode *IDom;
-  ETNode *ETN;
   std::vector<DomTreeNode*> Children;
   int DFSNumIn, DFSNumOut;
 
@@ -78,14 +77,10 @@ public:
   
   inline BasicBlock *getBlock() const { return TheBB; }
   inline DomTreeNode *getIDom() const { return IDom; }
-  inline ETNode *getETNode() const { return ETN; }
   inline const std::vector<DomTreeNode*> &getChildren() const { return Children; }
   
-  inline DomTreeNode(BasicBlock *BB, DomTreeNode *iDom, ETNode *E) 
-    : TheBB(BB), IDom(iDom), ETN(E), DFSNumIn(-1), DFSNumOut(-1) {
-    if (IDom)
-      ETN->setFather(IDom->getETNode());
-  }
+  inline DomTreeNode(BasicBlock *BB, DomTreeNode *iDom)
+    : TheBB(BB), IDom(iDom), DFSNumIn(-1), DFSNumOut(-1) { }
   inline DomTreeNode *addChild(DomTreeNode *C) { Children.push_back(C); return C; }
   void setIDom(DomTreeNode *NewIDom);
 
@@ -111,9 +106,6 @@ protected:
   DomTreeNodeMapType DomTreeNodes;
   DomTreeNode *RootNode;
 
-  typedef std::map<BasicBlock*, ETNode*> ETMapType;
-  ETMapType ETNodes;
-
   bool DFSInfoValid;
   unsigned int SlowQueries;
   // Information record used during immediate dominators computation.
@@ -197,17 +189,6 @@ protected:
 
   void updateDFSNumbers();  
 
-  /// Return the nearest common dominator of A and B.
-  BasicBlock *nearestCommonDominator(BasicBlock *A, BasicBlock *B) const  {
-    ETNode *NodeA = getNode(A)->getETNode();
-    ETNode *NodeB = getNode(B)->getETNode();
-    
-    ETNode *Common = NodeA->NCA(NodeB);
-    if (!Common)
-      return NULL;
-    return Common->getData<BasicBlock>();
-  }
-
   /// isReachableFromEntry - Return true if A is dominated by the entry
   /// block of the function containing it.
   const bool isReachableFromEntry(BasicBlock* A);
@@ -222,12 +203,8 @@ protected:
     if (A == 0 || B == 0)
       return false;
 
-    ETNode *NodeA = A->getETNode();
-    ETNode *NodeB = B->getETNode();
-    
     if (DFSInfoValid)
       return B->DominatedBy(A);
-      //return NodeB->DominatedBy(NodeA);
 
     // If we end up with too many slow queries, just update the
     // DFS numbers on the theory that we are going to keep querying.
@@ -235,9 +212,8 @@ protected:
     if (SlowQueries > 32) {
       updateDFSNumbers();
       return B->DominatedBy(A);
-      //return NodeB->DominatedBy(NodeA);
     }
-    //return NodeB->DominatedBySlow(NodeA);
+
     return dominatedBySlowTreeWalk(A, B);
   }
 
@@ -268,10 +244,8 @@ protected:
     DomTreeNode *IDomNode = getNode(DomBB);
     assert(IDomNode && "Not immediate dominator specified for block!");
     DFSInfoValid = false;
-    ETNode *E = new ETNode(BB);
-    ETNodes[BB] = E;
     return DomTreeNodes[BB] = 
-      IDomNode->addChild(new DomTreeNode(BB, IDomNode, E));
+      IDomNode->addChild(new DomTreeNode(BB, IDomNode));
   }
 
   /// changeImmediateDominator - This method is used to update the dominator
index 6d29c408d9aed8e5296d2f787e454cb0598f8ccb..091925ecc5197959ec58a7646100b21824532ee4 100644 (file)
@@ -51,30 +51,6 @@ private:
 };
 
 
-/// PostETForest Class - Concrete subclass of ETForestBase that is used to
-/// compute a forwards post-dominator ET-Forest.
-struct PostETForest : public ETForestBase {
-  static char ID;
-  PostETForest() : ETForestBase((intptr_t)&ID, true) {}
-
-  virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-    AU.setPreservesAll();
-    AU.addRequired<PostDominatorTree>();
-  }
-
-  virtual bool runOnFunction(Function &F) {
-    reset();     // Reset from the last time we were run...
-    PostDominatorTree &DT = getAnalysis<PostDominatorTree>();
-    Roots = DT.getRoots();
-    calculate(DT);
-    return false;
-  }
-
-  void calculate(const PostDominatorTree &DT);
-  ETNode *getNodeForBlock(BasicBlock *BB);
-};
-
-
 /// PostDominanceFrontier Class - Concrete subclass of DominanceFrontier that is
 /// used to compute the a post-dominance frontier.
 ///
index c4d42e9f3c38650bad755c52a55c9b55c1aaf0ab..48f7b30866f053b629fa8e91fd2f4e2a09dfae25 100644 (file)
@@ -24,7 +24,6 @@ using namespace llvm;
 
 char PostDominatorTree::ID = 0;
 char PostDominanceFrontier::ID = 0;
-char PostETForest::ID = 0;
 static RegisterPass<PostDominatorTree>
 F("postdomtree", "Post-Dominator Tree Construction", true);
 
@@ -165,9 +164,7 @@ void PostDominatorTree::calculate(Function &F) {
   // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0)
   // which postdominates all real exits if there are multiple exit blocks.
   BasicBlock *Root = Roots.size() == 1 ? Roots[0] : 0;
-  ETNode *ERoot = new ETNode(Root);
-  ETNodes[Root] = ERoot;
-  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0, ERoot);
+  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0);
   
   // Loop over all of the reachable blocks in the function...
   for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
@@ -179,9 +176,7 @@ void PostDominatorTree::calculate(Function &F) {
         
         // Add a new tree node for this BasicBlock, and link it as a child of
         // IDomNode
-        ETNode *ET = new ETNode(I);
-        ETNodes[I] = ET;
-        DomTreeNode *C = new DomTreeNode(I, IPDomNode, ET);
+        DomTreeNode *C = new DomTreeNode(I, IPDomNode);
         DomTreeNodes[I] = C;
         BBNode = IPDomNode->addChild(C);
       }
@@ -197,8 +192,8 @@ void PostDominatorTree::calculate(Function &F) {
   for (unsigned i = 0, e = Roots.size(); i != e; ++i)
     for (idf_iterator<BasicBlock*> I = idf_begin(Roots[i]),
            E = idf_end(Roots[i]); I != E; ++I) {
-      if (!getNodeForBlock(*I)->getETNode()->hasFather())
-        getNodeForBlock(*I)->getETNode()->assignDFSNumber(dfsnum);
+      if (!getNodeForBlock(*I)->getIDom())
+        getNodeForBlock(*I)->assignDFSNumber(dfsnum);
     }
   DFSInfoValid = true;
 }
@@ -215,79 +210,11 @@ DomTreeNode *PostDominatorTree::getNodeForBlock(BasicBlock *BB) {
   
   // Add a new tree node for this BasicBlock, and link it as a child of
   // IDomNode
-  ETNode *ET = new ETNode(BB);
-  ETNodes[BB] = ET;
-  DomTreeNode *C = new DomTreeNode(BB, IPDomNode, ET);
+  DomTreeNode *C = new DomTreeNode(BB, IPDomNode);
   DomTreeNodes[BB] = C;
   return BBNode = IPDomNode->addChild(C);
 }
 
-//===----------------------------------------------------------------------===//
-// PostETForest Implementation
-//===----------------------------------------------------------------------===//
-
-static RegisterPass<PostETForest>
-G("postetforest", "Post-ET-Forest Construction", true);
-
-ETNode *PostETForest::getNodeForBlock(BasicBlock *BB) {
-  ETNode *&BBNode = Nodes[BB];
-  if (BBNode) return BBNode;
-
-  // Haven't calculated this node yet?  Get or calculate the node for the
-  // immediate dominator.
-  DomTreeNode *node = getAnalysis<PostDominatorTree>().getNode(BB);
-
-  // If we are unreachable, we may not have an immediate dominator.
-  if (!node)
-    return 0;
-  else if (!node->getIDom())
-    return BBNode = new ETNode(BB);
-  else {
-    ETNode *IDomNode = getNodeForBlock(node->getIDom()->getBlock());
-    
-    // Add a new tree node for this BasicBlock, and link it as a child of
-    // IDomNode
-    BBNode = new ETNode(BB);
-    BBNode->setFather(IDomNode);
-    return BBNode;
-  }
-}
-
-void PostETForest::calculate(const PostDominatorTree &DT) {
-  for (unsigned i = 0, e = Roots.size(); i != e; ++i)
-    Nodes[Roots[i]] = new ETNode(Roots[i]); // Add a node for the root
-
-  // Iterate over all nodes in inverse depth first order.
-  for (unsigned i = 0, e = Roots.size(); i != e; ++i)
-    for (idf_iterator<BasicBlock*> I = idf_begin(Roots[i]),
-           E = idf_end(Roots[i]); I != E; ++I) {
-    BasicBlock *BB = *I;
-    ETNode *&BBNode = Nodes[BB];
-    if (!BBNode) {  
-      ETNode *IDomNode =  NULL;
-      DomTreeNode *node = DT.getNode(BB);
-      if (node && node->getIDom())
-        IDomNode = getNodeForBlock(node->getIDom()->getBlock());
-
-      // Add a new ETNode for this BasicBlock, and set it's parent
-      // to it's immediate dominator.
-      BBNode = new ETNode(BB);
-      if (IDomNode)          
-        BBNode->setFather(IDomNode);
-    }
-  }
-
-  int dfsnum = 0;
-  // Iterate over all nodes in depth first order...
-  for (unsigned i = 0, e = Roots.size(); i != e; ++i)
-    for (idf_iterator<BasicBlock*> I = idf_begin(Roots[i]),
-           E = idf_end(Roots[i]); I != E; ++I) {
-        if (!getNodeForBlock(*I)->hasFather())
-          getNodeForBlock(*I)->assignDFSNumber(dfsnum);
-    }
-  DFSInfoValid = true;
-}
-
 //===----------------------------------------------------------------------===//
 //  PostDominanceFrontier Implementation
 //===----------------------------------------------------------------------===//
index e6e1ffab7789d78e47dd1cab02436f74393a2591..4d125fb02238df110d5abe72696ecd68a942ad7a 100644 (file)
@@ -235,9 +235,7 @@ void DominatorTree::calculate(Function& F) {
   BasicBlock* Root = Roots[0];
 
   // Add a node for the root...
-  ETNode *ERoot = new ETNode(Root);
-  ETNodes[Root] = ERoot;
-  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0, ERoot);
+  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0);
 
   Vertex.push_back(0);
 
@@ -292,9 +290,7 @@ void DominatorTree::calculate(Function& F) {
 
         // Add a new tree node for this BasicBlock, and link it as a child of
         // IDomNode
-        ETNode *ET = new ETNode(I);
-        ETNodes[I] = ET;
-        DomTreeNode *C = new DomTreeNode(I, IDomNode, ET);
+        DomTreeNode *C = new DomTreeNode(I, IDomNode);
         DomTreeNodes[I] = C;
         BBNode = IDomNode->addChild(C);
       }
@@ -320,9 +316,6 @@ void DominatorTreeBase::updateDFSNumbers()
       if (BBNode) {
         if (!BBNode->getIDom())
           BBNode->assignDFSNumber(dfsnum);
-        //ETNode *ETN = BBNode->getETNode();
-        //if (ETN && !ETN->hasFather())
-        //  ETN->assignDFSNumber(dfsnum);
       }
   }
   SlowQueries = 0;
@@ -472,13 +465,6 @@ void DomTreeNode::setIDom(DomTreeNode *NewIDom) {
     // Switch to new dominator
     IDom = NewIDom;
     IDom->Children.push_back(this);
-
-    if (!ETN->hasFather())
-      ETN->setFather(IDom->getETNode());
-    else if (ETN->getFather()->getData<BasicBlock>() != IDom->getBlock()) {
-        ETN->Split();
-        ETN->setFather(IDom->getETNode());
-    }
   }
 }
 
@@ -493,9 +479,7 @@ DomTreeNode *DominatorTree::getNodeForBlock(BasicBlock *BB) {
 
   // Add a new tree node for this BasicBlock, and link it as a child of
   // IDomNode
-  ETNode *ET = new ETNode(BB);
-  ETNodes[BB] = ET;
-  DomTreeNode *C = new DomTreeNode(BB, IDomNode, ET);
+  DomTreeNode *C = new DomTreeNode(BB, IDomNode);
   DomTreeNodes[BB] = C;
   return BBNode = IDomNode->addChild(C);
 }