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

Chris Lattner lattner at cs.uiuc.edu
Wed Mar 23 12:09:16 PST 2005



Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.228 -> 1.229
---
Log message:

Totally gut mergeInGraph.  There is absolutely no reason to be merging 
global roots in from callees to callers.  The BU graphs do not have accurate
globals information and all of the clients know it.  Instead, just make sure
the GG is up-to-date, and they will be perfectly satiated.

This speeds up the BU pass on 176.gcc from 5.5s to 1.5s, and Loc+BU+TD
from 7s to 2.7s.


---
Diffs of the changes:  (+48 -74)

 DataStructure.cpp |  122 +++++++++++++++++++++---------------------------------
 1 files changed, 48 insertions(+), 74 deletions(-)


Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.228 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.229
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.228	Wed Mar 23 10:43:11 2005
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Wed Mar 23 14:08:59 2005
@@ -1348,95 +1348,69 @@
   TIME_REGION(X, "mergeInGraph");
 
   // If this is not a recursive call, clone the graph into this graph...
-  if (&Graph != this) {
-    // Clone the callee's graph into the current graph, keeping track of where
-    // scalars in the old graph _used_ to point, and of the new nodes matching
-    // nodes of the old graph.
-    ReachabilityCloner RC(*this, Graph, CloneFlags);
+  if (&Graph == this) {
+    // Merge the return value with the return value of the context.
+    Args[0].mergeWith(CS.getRetVal());
     
-    // Map the return node pointer over.
-    if (!CS.getRetVal().isNull())
-      RC.merge(CS.getRetVal(), Args[0]);
-
-    // Map over all of the arguments.
+    // Resolve all of the function arguments.
     for (unsigned i = 0, e = CS.getNumPtrArgs(); i != e; ++i) {
       if (i == Args.size()-1)
         break;
       
       // Add the link from the argument scalar to the provided value.
-      RC.merge(CS.getPtrArg(i), Args[i+1]);
-    }
-    
-    // If requested, copy all of the calls.
-    if (!(CloneFlags & DontCloneCallNodes)) {
-      // Copy the function calls list.
-      for (fc_iterator I = Graph.fc_begin(), E = Graph.fc_end(); I != E; ++I)
-        FunctionCalls.push_back(DSCallSite(*I, RC));
+      Args[i+1].mergeWith(CS.getPtrArg(i));
     }
+    return;
+  }
 
-    // If the user has us copying aux calls (the normal case), set up a data
-    // structure to keep track of which ones we've copied over.
-    std::set<const DSCallSite*> CopiedAuxCall;
+  // Clone the callee's graph into the current graph, keeping track of where
+  // scalars in the old graph _used_ to point, and of the new nodes matching
+  // nodes of the old graph.
+  ReachabilityCloner RC(*this, Graph, CloneFlags);
     
-    // Clone over all globals that appear in the caller and callee graphs.
-    hash_set<GlobalVariable*> NonCopiedGlobals;
-    for (DSScalarMap::global_iterator GI = Graph.getScalarMap().global_begin(),
-           E = Graph.getScalarMap().global_end(); GI != E; ++GI)
-      if (GlobalVariable *GV = dyn_cast<GlobalVariable>(*GI))
-        if (ScalarMap.count(GV))
-          RC.merge(ScalarMap[GV], Graph.getNodeForValue(GV));
-        else
-          NonCopiedGlobals.insert(GV);
+  // Map the return node pointer over.
+  if (!CS.getRetVal().isNull())
+    RC.merge(CS.getRetVal(), Args[0]);
+
+  // Map over all of the arguments.
+  for (unsigned i = 0, e = CS.getNumPtrArgs(); i != e; ++i) {
+    if (i == Args.size()-1)
+      break;
+      
+    // Add the link from the argument scalar to the provided value.
+    RC.merge(CS.getPtrArg(i), Args[i+1]);
+  }
     
-    // If the global does not appear in the callers graph we generally don't
-    // want to copy the node.  However, if there is a path from the node global
-    // node to a node that we did copy in the graph, we *must* copy it to
-    // maintain the connection information.  Every time we decide to include a
-    // new global, this might make other globals live, so we must iterate
-    // unfortunately.
-    bool MadeChange = true;
+  // If requested, copy all of the calls.
+  if (!(CloneFlags & DontCloneCallNodes)) {
+    // Copy the function calls list.
+    for (fc_iterator I = Graph.fc_begin(), E = Graph.fc_end(); I != E; ++I)
+      FunctionCalls.push_back(DSCallSite(*I, RC));
+  }
+
+  // If the user has us copying aux calls (the normal case), set up a data
+  // structure to keep track of which ones we've copied over.
+  std::set<const DSCallSite*> CopiedAuxCall;
+    
+  // If the global does not appear in the callers graph we generally don't
+  // want to copy the node.  However, if there is a path from the node global
+  // node to a node that we did copy in the graph, we *must* copy it to
+  // maintain the connection information.  Every time we decide to include a
+  // new global, this might make other globals live, so we must iterate
+  // unfortunately.
+  bool MadeChange = true;
+  if (!(CloneFlags & DontCloneAuxCallNodes))
     while (MadeChange) {
       MadeChange = false;
-      for (hash_set<GlobalVariable*>::iterator I = NonCopiedGlobals.begin();
-           I != NonCopiedGlobals.end();) {
-        DSNode *GlobalNode = Graph.getNodeForValue(*I).getNode();
-        if (RC.hasClonedNode(GlobalNode)) {
-          // Already cloned it, remove from set.
-          NonCopiedGlobals.erase(I++);
-          MadeChange = true;
-        } else if (PathExistsToClonedNode(GlobalNode, RC)) {
-          RC.getClonedNH(Graph.getNodeForValue(*I));
-          NonCopiedGlobals.erase(I++);
-          MadeChange = true;
-        } else {
-          ++I;
-        }
-      }
 
       // If requested, copy any aux calls that can reach copied nodes.
-      if (!(CloneFlags & DontCloneAuxCallNodes)) {
-        for (afc_iterator I = Graph.afc_begin(), E = Graph.afc_end(); I!=E; ++I)
-          if (CopiedAuxCall.insert(&*I).second &&
-              PathExistsToClonedNode(*I, RC)) {
-            AuxFunctionCalls.push_back(DSCallSite(*I, RC));
-            MadeChange = true;
-          }
-      }
-    }
-    
-  } else {
-    // Merge the return value with the return value of the context.
-    Args[0].mergeWith(CS.getRetVal());
-    
-    // Resolve all of the function arguments.
-    for (unsigned i = 0, e = CS.getNumPtrArgs(); i != e; ++i) {
-      if (i == Args.size()-1)
-        break;
-      
-      // Add the link from the argument scalar to the provided value.
-      Args[i+1].mergeWith(CS.getPtrArg(i));
+      for (afc_iterator I = Graph.afc_begin(), E = Graph.afc_end(); I!=E; ++I)
+        if (CopiedAuxCall.insert(&*I).second &&
+            PathExistsToClonedNode(*I, RC)) {
+          AuxFunctionCalls.push_back(DSCallSite(*I, RC));
+          MadeChange = true;
+        }
     }
-  }
 }
 
 






More information about the llvm-commits mailing list