[llvm-commits] CVS: llvm/lib/Analysis/PostDominators.cpp

Devang Patel dpatel at apple.com
Thu Jun 7 10:47:54 PDT 2007



Changes in directory llvm/lib/Analysis:

PostDominators.cpp updated: 1.72 -> 1.73
---
Log message:

Maintain ETNode as part of DomTreeNode. 
This adds redundancy for now.


---
Diffs of the changes:  (+24 -4)

 PostDominators.cpp |   28 ++++++++++++++++++++++++----
 1 files changed, 24 insertions(+), 4 deletions(-)


Index: llvm/lib/Analysis/PostDominators.cpp
diff -u llvm/lib/Analysis/PostDominators.cpp:1.72 llvm/lib/Analysis/PostDominators.cpp:1.73
--- llvm/lib/Analysis/PostDominators.cpp:1.72	Sun Jun  3 19:32:21 2007
+++ llvm/lib/Analysis/PostDominators.cpp	Thu Jun  7 12:47:21 2007
@@ -165,7 +165,9 @@
   // 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;
-  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0);
+  ETNode *ERoot = new ETNode(Root);
+  ETNodes[Root] = ERoot;
+  DomTreeNodes[Root] = RootNode = new DomTreeNode(Root, 0, ERoot);
   
   // Loop over all of the reachable blocks in the function...
   for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
@@ -177,7 +179,11 @@
         
         // Add a new tree node for this BasicBlock, and link it as a child of
         // IDomNode
-        BBNode = IPDomNode->addChild(new DomTreeNode(I, IPDomNode));
+        ETNode *ET = new ETNode(I);
+        ETNodes[I] = ET;
+        DomTreeNode *C = new DomTreeNode(I, IPDomNode, ET);
+        DomTreeNodes[I] = C;
+        BBNode = IPDomNode->addChild(C);
       }
     }
 
@@ -185,6 +191,16 @@
   IDoms.clear();
   Info.clear();
   std::vector<BasicBlock*>().swap(Vertex);
+
+  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)->getETNode()->hasFather())
+        getNodeForBlock(*I)->getETNode()->assignDFSNumber(dfsnum);
+    }
+  DFSInfoValid = true;
 }
 
 
@@ -199,7 +215,11 @@
   
   // Add a new tree node for this BasicBlock, and link it as a child of
   // IDomNode
-  return BBNode = IPDomNode->addChild(new DomTreeNode(BB, IPDomNode));
+  ETNode *ET = new ETNode(BB);
+  ETNodes[BB] = ET;
+  DomTreeNode *C = new DomTreeNode(BB, IPDomNode, ET);
+  DomTreeNodes[BB] = C;
+  return BBNode = IPDomNode->addChild(C);
 }
 
 //===----------------------------------------------------------------------===//
@@ -303,7 +323,7 @@
 
     DomSetType::const_iterator CDFI = ChildDF.begin(), CDFE = ChildDF.end();
     for (; CDFI != CDFE; ++CDFI) {
-      if (!Node->properlyDominates(DT[*CDFI]))
+      if (!DT.properlyDominates(Node, DT[*CDFI]))
         S.insert(*CDFI);
     }
   }






More information about the llvm-commits mailing list