Do not revisit nodes in the SCC traversal.  This speeds up the BU pass a bit.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19968 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp
index 4774664..555c423 100644
--- a/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -40,9 +40,13 @@
   GlobalsGraph = new DSGraph(LocalDSA.getGlobalsGraph());
   GlobalsGraph->setPrintAuxCalls();
 
+  std::vector<Function*> Stack;
+  hash_map<Function*, unsigned> ValMap;
+  unsigned NextID = 1;
+
   Function *MainFunc = M.getMainFunction();
   if (MainFunc)
-    calculateReachableGraphs(MainFunc);
+    calculateGraphs(MainFunc, Stack, NextID, ValMap);
 
   // Calculate the graphs for any functions that are unreachable from main...
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
@@ -52,7 +56,7 @@
         std::cerr << "*** Function unreachable from main: "
                   << I->getName() << "\n";
 #endif
-      calculateReachableGraphs(I);    // Calculate all graphs...
+      calculateGraphs(I, Stack, NextID, ValMap);     // Calculate all graphs.
     }
 
   NumCallEdges += ActualCallees.size();
@@ -69,10 +73,6 @@
 }
 
 void BUDataStructures::calculateReachableGraphs(Function *F) {
-  std::vector<Function*> Stack;
-  hash_map<Function*, unsigned> ValMap;
-  unsigned NextID = 1;
-  calculateGraphs(F, Stack, NextID, ValMap);
 }
 
 DSGraph &BUDataStructures::getOrCreateGraph(Function *F) {
@@ -253,7 +253,29 @@
 
   DSGraph::ReturnNodesTy &ReturnNodes = Graph.getReturnNodes();
 
-  // Loop over all of the resolvable call sites
+  // Print out multi-call sites.
+  bool Printed = false;
+  for (std::list<DSCallSite>::iterator I = TempFCs.begin(), E = TempFCs.end();
+       I != E; ++I) {
+    if (!I->isDirectCall()) {
+      DSNode *Node = I->getCalleeNode();
+      if (Node->getGlobals().size() > 1) {
+        if (!Printed)
+          std::cerr << "In Fns: " << Graph.getFunctionNames() << "\n";
+        std::cerr << "  calls " << Node->getGlobals().size()
+                  << " fns from site: " << *I->getCallSite().getInstruction();
+        unsigned NumToPrint = Node->getGlobals().size();
+        if (NumToPrint > 5) NumToPrint = 5;
+        std::cerr << "   Fns =";
+        for (unsigned i = 0; i != NumToPrint; ++i) 
+          std::cerr << " " << Node->getGlobals()[i]->getName();
+        std::cerr << "\n";
+      }
+    }
+  }
+
+
+  // Loop over all of the resolvable call sites.
   DSCallSiteIterator I = DSCallSiteIterator::begin(TempFCs);
   DSCallSiteIterator E = DSCallSiteIterator::end(TempFCs);