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

Chris Lattner lattner at cs.uiuc.edu
Fri Feb 4 11:58:41 PST 2005



Changes in directory llvm/lib/Analysis/DataStructure:

DataStructure.cpp updated: 1.189 -> 1.190
---
Log message:

Split mergeInGraph into two methods.


---
Diffs of the changes:  (+28 -29)

 DataStructure.cpp |   57 ++++++++++++++++++++++++++----------------------------
 1 files changed, 28 insertions(+), 29 deletions(-)


Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.189 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.190
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.189	Thu Feb  3 12:40:25 2005
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp	Fri Feb  4 13:58:28 2005
@@ -1257,19 +1257,16 @@
     }
 }
 
-/// mergeInGraph - The method is used for merging graphs together.  If the
-/// argument graph is not *this, it makes a clone of the specified graph, then
-/// merges the nodes specified in the call site with the formal arguments in the
-/// graph.
+/// mergeInCallFromOtherGraph - This graph merges in the minimal number of
+/// nodes from G2 into 'this' graph, merging the bindings specified by the
+/// call site (in this graph) with the bindings specified by the vector in G2.
+/// The two DSGraphs must be different.
 ///
-void DSGraph::mergeInGraph(const DSCallSite &CS, Function &F,
+void DSGraph::mergeInGraph(const DSCallSite &CS, 
+                           std::vector<DSNodeHandle> &Args,
                            const DSGraph &Graph, unsigned CloneFlags) {
   TIME_REGION(X, "mergeInGraph");
 
-  // Fastpath for a noop inline.
-  if (CS.getNumPtrArgs() == 0 && CS.getRetVal().isNull())
-    return;
-
   // 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
@@ -1277,23 +1274,14 @@
     // nodes of the old graph.
     ReachabilityCloner RC(*this, Graph, CloneFlags);
     
-    // Set up argument bindings.
-    std::vector<DSNodeHandle> Args;
-    Graph.getFunctionArgumentsForCall(&F, Args);
-
     // 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) {
-#ifndef NDEBUG  // FIXME: We should merge vararg arguments!
-        if (!F.getFunctionType()->isVarArg())
-          std::cerr << "Bad call to Function: " << F.getName() << "\n";
-#endif
+      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]);
@@ -1357,22 +1345,13 @@
     }
     
   } else {
-    // Set up argument bindings.
-    std::vector<DSNodeHandle> Args;
-    Graph.getFunctionArgumentsForCall(&F, Args);
-
     // 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) {
-#ifndef NDEBUG // FIXME: We should merge varargs arguments!!
-        if (!F.getFunctionType()->isVarArg())
-          std::cerr << "Bad call to Function: " << F.getName() << "\n";
-#endif
+      if (i == Args.size()-1)
         break;
-      }
       
       // Add the link from the argument scalar to the provided value.
       Args[i+1].mergeWith(CS.getPtrArg(i));
@@ -1380,6 +1359,26 @@
   }
 }
 
+
+
+/// mergeInGraph - The method is used for merging graphs together.  If the
+/// argument graph is not *this, it makes a clone of the specified graph, then
+/// merges the nodes specified in the call site with the formal arguments in the
+/// graph.
+///
+void DSGraph::mergeInGraph(const DSCallSite &CS, Function &F,
+                           const DSGraph &Graph, unsigned CloneFlags) {
+  // Fastpath for a noop inline.
+  if (CS.getNumPtrArgs() == 0 && CS.getRetVal().isNull())
+    return;
+
+  // Set up argument bindings.
+  std::vector<DSNodeHandle> Args;
+  Graph.getFunctionArgumentsForCall(&F, Args);
+
+  mergeInGraph(CS, Args, Graph, CloneFlags);
+}
+
 /// getCallSiteForArguments - Get the arguments and return value bindings for
 /// the specified function in the current graph.
 ///






More information about the llvm-commits mailing list