[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Printer.cpp TopDownClosure.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Nov 7 19:22:01 PST 2002


Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.49 -> 1.50
Printer.cpp updated: 1.35 -> 1.36
TopDownClosure.cpp updated: 1.21 -> 1.22

---
Log message:

Add flush


---
Diffs of the changes:

Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.49 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.50
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.49	Thu Nov  7 01:06:20 2002
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Thu Nov  7 19:21:07 2002
@@ -17,7 +17,8 @@
 using std::vector;
 
 namespace {
-  Statistic<> NumFolds("dsnode", "Number of nodes completely folded");
+  Statistic<> NumFolds          ("dsnode", "Number of nodes completely folded");
+  Statistic<> NumCallNodesMerged("dsnode", "Number of call nodes merged");
 };
 
 namespace DS {   // TODO: FIXME
@@ -443,7 +444,7 @@
 
   // Merge the node types
   NodeType |= N->NodeType;
-  N->NodeType = 0;   // N is now a dead node.
+  N->NodeType = DEAD;   // N is now a dead node.
 
   // Merge the globals list...
   if (!N->Globals.empty()) {
@@ -497,17 +498,6 @@
 void DSGraph::dump() const { print(std::cerr); }
 
 
-// Helper function used to clone a function list.
-// 
-static void CopyFunctionCallsList(const vector<DSCallSite>& fromCalls,
-                                  vector<DSCallSite> &toCalls,
-                                  std::map<const DSNode*, DSNode*> &NodeMap) {
-  unsigned FC = toCalls.size();  // FirstCall
-  toCalls.reserve(FC+fromCalls.size());
-  for (unsigned i = 0, ei = fromCalls.size(); i != ei; ++i)
-    toCalls.push_back(DSCallSite(fromCalls[i], NodeMap));
-}
-
 /// remapLinks - Change all of the Links in the current node according to the
 /// specified mapping.
 ///
@@ -528,6 +518,7 @@
                                 std::map<const DSNode*, DSNode*> &OldNodeMap,
                                 AllocaBit StripAllocas) {
   assert(OldNodeMap.empty() && "Returned OldNodeMap should be empty!");
+  assert(&G != this && "Cannot clone graph into itself!");
 
   unsigned FN = Nodes.size();           // First new node...
 
@@ -560,14 +551,18 @@
       std::map<Value*, DSNodeHandle>::iterator GVI = ScalarMap.find(I->first);
       if (GVI != ScalarMap.end()) {   // Is the global value in this fn already?
         GVI->second.mergeWith(H);
+        OldNodeMap[I->second.getNode()] = H.getNode();
       } else {
         ScalarMap[I->first] = H;      // Add global pointer to this graph
       }
     }
   }
-  // Copy the function calls list...
-  CopyFunctionCallsList(G.FunctionCalls, FunctionCalls, OldNodeMap);
 
+  // Copy the function calls list...
+  unsigned FC = FunctionCalls.size();  // FirstCall
+  FunctionCalls.reserve(FC+G.FunctionCalls.size());
+  for (unsigned i = 0, ei = G.FunctionCalls.size(); i != ei; ++i)
+    FunctionCalls.push_back(DSCallSite(G.FunctionCalls[i], OldNodeMap));
 
   // Return the returned node pointer...
   return DSNodeHandle(OldNodeMap[G.RetNode.getNode()], G.RetNode.getOffset());
@@ -729,7 +724,8 @@
 //
 bool DSGraph::isNodeDead(DSNode *N) {
   // Is it a trivially dead shadow node...
-  if (N->getReferrers().empty() && N->NodeType == 0)
+  if (N->getReferrers().empty() &&
+      (N->NodeType == 0 || N->NodeType == DSNode::DEAD))
     return true;
 
   // Is it a function node or some other trivially unused global?
@@ -754,6 +750,9 @@
   Calls.erase(std::unique(Calls.begin(), Calls.end()),
               Calls.end());
 
+  // Track the number of call nodes merged away...
+  NumCallNodesMerged += NumFns-Calls.size();
+
   DEBUG(if (NumFns != Calls.size())
           std::cerr << "Merged " << (NumFns-Calls.size())
                     << " call nodes in " << where << "\n";);
@@ -936,7 +935,7 @@
 // inlining graphs.
 //
 void DSGraph::removeDeadNodes(bool KeepAllGlobals, bool KeepCalls) {
-  assert((!KeepAllGlobals || KeepCalls) &&
+  assert((!KeepAllGlobals || KeepCalls) &&  // FIXME: This should be an enum!
          "KeepAllGlobals without KeepCalls is meaningless");
 
   // Reduce the amount of work we have to do...
@@ -961,22 +960,13 @@
          E = ScalarMap.end(); I != E; ++I)
     markAlive(I->second.getNode(), Alive);
 
-#if 0
-  // Marge all nodes reachable by global nodes, as alive.  Isn't this covered by
-  // the ScalarMap?
-  //
-  if (KeepAllGlobals)
-    for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
-      if (Nodes[i]->NodeType & DSNode::GlobalNode)
-        markAlive(Nodes[i], Alive);
-#endif
-
   // The return value is alive as well...
   markAlive(RetNode.getNode(), Alive);
 
   // Mark all globals or cast nodes that can reach a live node as alive.
   // This also marks all nodes reachable from such nodes as alive.
   // Of course, if KeepAllGlobals is specified, they would be live already.
+
   if (!KeepAllGlobals)
     markGlobalsAlive(*this, Alive, !KeepCalls);
 


Index: llvm/lib/Analysis/DataStructure/Printer.cpp
diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.35 llvm/lib/Analysis/DataStructure/Printer.cpp:1.36
--- llvm/lib/Analysis/DataStructure/Printer.cpp:1.35	Wed Nov  6 20:18:46 2002
+++ llvm/lib/Analysis/DataStructure/Printer.cpp	Thu Nov  7 19:21:07 2002
@@ -182,7 +182,7 @@
     }
 
   O << "\nGraphs contain [" << TotalNumNodes << "+" << TotalCallNodes 
-    << "] nodes total\n";
+    << "] nodes total" << std::endl;
 }
 
 


Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.21 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.22
--- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.21	Thu Nov  7 01:06:20 2002
+++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp	Thu Nov  7 19:21:07 2002
@@ -138,7 +138,8 @@
   // Loop over all call sites of this function, merging each one into this
   // graph.
   //
-  DEBUG(std::cerr << "  [TD] Inlining callers for: " << F.getName() << "\n");
+  DEBUG(std::cerr << "  [TD] Inlining " << CallSitesP->size()
+                  << " callers for: " << F.getName() << "\n");
   const std::vector<DSCallSite> &CallSites = *CallSitesP;
   for (unsigned c = 0, ce = CallSites.size(); c != ce; ++c) {
     const DSCallSite &CallSite = CallSites[c];





More information about the llvm-commits mailing list