Add MaxSCC statistics
authorChris Lattner <sabre@nondot.org>
Sun, 17 Nov 2002 22:16:28 +0000 (22:16 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 17 Nov 2002 22:16:28 +0000 (22:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4722 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/DataStructure/BottomUpClosure.cpp

index 435cb1beafc9eb4459081fc1c6b534221e5c9298..d8ae1de7be0f76ab471af96eb8833d176187172e 100644 (file)
 #include "Support/Statistic.h"
 using std::map;
 
-static RegisterAnalysis<BUDataStructures>
-X("budatastructure", "Bottom-up Data Structure Analysis Closure");
+namespace {
+  Statistic<> MaxSCC("budatastructure", "Maximum SCC Size in Call Graph");
+  
+  RegisterAnalysis<BUDataStructures>
+  X("budatastructure", "Bottom-up Data Structure Analysis Closure");
+}
 
 using namespace DS;
 
@@ -112,9 +116,11 @@ bool BUDataStructures::run(Module &M) {
   // Calculate the graphs for any functions that are unreachable from main...
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
     if (!I->isExternal() && DSInfo.find(I) == DSInfo.end()) {
+#ifndef NDEBUG
       if (MainFunc)
         std::cerr << "*** Function unreachable from main: "
                   << I->getName() << "\n";
+#endif
       calculateReachableGraphs(I);    // Calculate all graphs...
     }
   return false;
@@ -186,6 +192,8 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
     Stack.pop_back();
     DSGraph &G = calculateGraph(*F);
 
+    if (MaxSCC < 1) MaxSCC = 1;
+
     // Should we revisit the graph?
     if (CallSiteIterator::begin(G) != CallSiteIterator::end(G)) {
       ValMap.erase(F);
@@ -211,6 +219,10 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
     std::cerr << "Identified SCC #: " << MyID << " of size: "
               << (Stack.end()-FirstInSCC) << "\n";
 
+    // Compute the Max SCC Size...
+    if (MaxSCC < unsigned(Stack.end()-FirstInSCC))
+      MaxSCC = Stack.end()-FirstInSCC;
+
     std::vector<Function*>::iterator I = Stack.end();
     do {
       --I;
@@ -325,10 +337,20 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) {
       DEBUG(std::cerr << "    Inlining graph for " << Callee->getName()
             << " in: " << F.getName() << "[" << GI.getGraphSize() << "+"
             << GI.getAuxFunctionCalls().size() << "]\n");
+
+#if 0
+      Graph.writeGraphToFile(std::cerr, "bu_" + F.getName() + "_before_" +
+                             Callee->getName());
+#endif
       
       // Handle self recursion by resolving the arguments and return value
       Graph.mergeInGraph(CS, GI, DSGraph::StripAllocaBit |
                          DSGraph::DontCloneCallNodes);
+
+#if 0
+      Graph.writeGraphToFile(std::cerr, "bu_" + F.getName() + "_after_" +
+                             Callee->getName());
+#endif
     }
   }
 
@@ -400,7 +422,7 @@ DSGraph &BUDataStructures::inlineNonSCCGraphs(Function &F,
       DEBUG(std::cerr << "    Inlining graph for " << Callee->getName()
             << " in: " << F.getName() << "[" << GI.getGraphSize() << "+"
             << GI.getAuxFunctionCalls().size() << "]\n");
-      
+
       // Handle self recursion by resolving the arguments and return value
       Graph.mergeInGraph(CS, GI, DSGraph::StripAllocaBit |
                          DSGraph::DontCloneCallNodes);
@@ -423,8 +445,6 @@ DSGraph &BUDataStructures::inlineNonSCCGraphs(Function &F,
         << Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
         << "]\n");
 
-  //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName());
-
   return Graph;
 }
 
@@ -518,7 +538,6 @@ DSGraph &BUDataStructures::calculateSCCGraph(Function &F,
   DEBUG(std::cerr << "  [BU] Done inlining: " << F.getName() << " ["
         << Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
         << "]\n");
-
   //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName());
 
   return Graph;