getNodes() is gone, use node_begin/end instead
authorChris Lattner <sabre@nondot.org>
Sat, 7 Feb 2004 23:58:05 +0000 (23:58 +0000)
committerChris Lattner <sabre@nondot.org>
Sat, 7 Feb 2004 23:58:05 +0000 (23:58 +0000)
Rename stats from dsnode -> dsa
Add a new stat

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

lib/Analysis/DataStructure/DataStructure.cpp
lib/Analysis/DataStructure/GraphChecker.cpp
lib/Analysis/DataStructure/Printer.cpp

index 5050515bc288bafe41070c5fb5942f3a151f73ab..ca1d8c623da642b599c928019004033bcd4bf83e 100644 (file)
 using namespace llvm;
 
 namespace {
-  Statistic<> NumFolds          ("dsnode", "Number of nodes completely folded");
-  Statistic<> NumCallNodesMerged("dsnode", "Number of call nodes merged");
-  Statistic<> NumNodeAllocated  ("dsnode", "Number of nodes allocated");
+  Statistic<> NumFolds          ("dsa", "Number of nodes completely folded");
+  Statistic<> NumCallNodesMerged("dsa", "Number of call nodes merged");
+  Statistic<> NumNodeAllocated  ("dsa", "Number of nodes allocated");
+  Statistic<> NumDNE            ("dsa", "Number of nodes removed by reachability");
 
   cl::opt<bool>
   EnableDSNodeGlobalRootsHack("enable-dsa-globalrootshack", cl::Hidden,
@@ -73,7 +74,7 @@ DSNode::DSNode(const Type *T, DSGraph *G)
   : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::VoidTy), NodeType(0) {
   // Add the type entry if it is specified...
   if (T) mergeTypeInfo(T, 0);
-  G->getNodes().push_back(this);
+  G->addNode(this);
   ++NumNodeAllocated;
 }
 
@@ -85,7 +86,7 @@ DSNode::DSNode(const DSNode &N, DSGraph *G, bool NullLinks)
     Links = N.Links;
   else
     Links.resize(N.Links.size()); // Create the appropriate number of null links
-  G->getNodes().push_back(this);
+  G->addNode(this);
   ++NumNodeAllocated;
 }
 
@@ -1757,6 +1758,7 @@ void DSGraph::removeDeadNodes(unsigned Flags) {
   DeadNodes.reserve(Nodes.size());
   for (unsigned i = 0; i != Nodes.size(); ++i)
     if (!Alive.count(Nodes[i])) {
+      ++NumDNE;
       DSNode *N = Nodes[i];
       Nodes[i--] = Nodes.back();            // move node to end of vector
       Nodes.pop_back();                     // Erase node from alive list.
index 6d78621c11c87c26bad13f5593bc5b7069d9f21f..5cbd5ba762997853a612aee5665ed0d6109c1082 100644 (file)
@@ -114,11 +114,10 @@ bool DSGC::runOnFunction(Function &F) {
 void DSGC::verify(const DSGraph &G) {
   // Loop over all of the nodes, checking to see if any are collapsed...
   if (AbortIfAnyCollapsed) {
-    const std::vector<DSNode*> &Nodes = G.getNodes();
-    for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
-      if (Nodes[i]->isNodeCompletelyFolded()) {
+    for (DSGraph::node_iterator I = G.node_begin(), E = G.node_end(); I!=E; ++I)
+      if ((*I)->isNodeCompletelyFolded()) {
         std::cerr << "Node is collapsed: ";
-        Nodes[i]->print(std::cerr, &G);
+        (*I)->print(std::cerr, &G);
         abort();
       }
   }
index 7cea561c1480041a051da12d779c33534fb2d3ca..a5cb4da0b1b1856ee15d4cd4ad0955b7dec04e0a 100644 (file)
@@ -30,8 +30,8 @@ using namespace llvm;
 namespace {
   cl::opt<bool> OnlyPrintMain("only-print-main-ds", cl::ReallyHidden);
   cl::opt<bool> DontPrintAnything("dont-print-ds", cl::ReallyHidden);
-  Statistic<> MaxGraphSize   ("dsnode", "Maximum graph size");
-  Statistic<> NumFoldedNodes ("dsnode", "Number of folded nodes (in final graph)");
+  Statistic<> MaxGraphSize   ("dsa", "Maximum graph size");
+  Statistic<> NumFoldedNodes ("dsa", "Number of folded nodes (in final graph)");
 }
 
 void DSNode::dump() const { print(std::cerr, 0); }
@@ -249,10 +249,12 @@ static void printCollection(const Collection &C, std::ostream &O,
           << Gr.getGraphSize() << "+" << NumCalls << "]\n";
       }
 
-      if (MaxGraphSize < Gr.getNodes().size())
-        MaxGraphSize = Gr.getNodes().size();
-      for (unsigned i = 0, e = Gr.getNodes().size(); i != e; ++i)
-        if (Gr.getNodes()[i]->isNodeCompletelyFolded())
+      unsigned GraphSize = std::distance(Gr.node_begin(), Gr.node_end());
+      if (MaxGraphSize < GraphSize) MaxGraphSize = GraphSize;
+
+      for (DSGraph::node_iterator NI = Gr.node_begin(), E = Gr.node_end();
+           NI != E; ++NI)
+        if ((*NI)->isNodeCompletelyFolded())
           ++NumFoldedNodes;
     }