summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-07 06:31:54 +0000
committerChris Lattner <sabre@nondot.org>2002-11-07 06:31:54 +0000
commitdf307e6fd0964dc81dd8cbc8bfefb6ace6298508 (patch)
tree36f38a9cdc13bb1d5e7c2c6c0efb9e73169887fb /llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
parent8d493b51db48bc19ac7fbf965e0f245a849472fd (diff)
downloadbcm5719-llvm-df307e6fd0964dc81dd8cbc8bfefb6ace6298508.tar.gz
bcm5719-llvm-df307e6fd0964dc81dd8cbc8bfefb6ace6298508.zip
Implement a new mergeInGraph method, which basically factors code out of
the BU class. This will be used by the IPModRef class to do stuff, eventually perhaps the TD pass will use it also. Speaking of the TD pass, this also eliminates the self recursive case, which was broken, and couldn't occur anyway. llvm-svn: 4599
Diffstat (limited to 'llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp')
-rw-r--r--llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp48
1 files changed, 4 insertions, 44 deletions
diff --git a/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp b/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
index 02a9e64408c..cbe53ce68e2 100644
--- a/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -46,29 +46,6 @@ bool BUDataStructures::run(Module &M) {
return false;
}
-// ResolveArguments - Resolve the formal and actual arguments for a function
-// call.
-//
-static void ResolveArguments(DSCallSite &Call, Function &F,
- map<Value*, DSNodeHandle> &ScalarMap) {
- // Resolve all of the function arguments...
- Function::aiterator AI = F.abegin();
- for (unsigned i = 0, e = Call.getNumPtrArgs(); i != e; ++i, ++AI) {
- // Advance the argument iterator to the first pointer argument...
- while (!isPointerType(AI->getType())) {
- ++AI;
-#ifndef NDEBUG
- if (AI == F.aend())
- std::cerr << "Bad call to Function: " << F.getName() << "\n";
-#endif
- assert(AI != F.aend() && "# Args provided is not # Args required!");
- }
-
- // Add the link from the argument scalar to the provided value
- ScalarMap[AI].mergeWith(Call.getPtrArg(i));
- }
-}
-
DSGraph &BUDataStructures::calculateGraph(Function &F) {
// Make sure this graph has not already been calculated, or that we don't get
// into an infinite loop with mutually recursive functions.
@@ -115,11 +92,8 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) {
// actual arguments...
DEBUG(std::cerr << "\t[BU] Self Inlining: " << F.getName() << "\n");
- // Handle the return value if present...
- Graph->getRetNode().mergeWith(Call.getRetVal());
-
- // Resolve the arguments in the call to the actual values...
- ResolveArguments(Call, F, Graph->getScalarMap());
+ // Handle self recursion by resolving the arguments and return value
+ Graph->mergeInGraph(Call, *Graph, true);
// Erase the entry in the callees vector
Callees.erase(Callees.begin()+c--);
@@ -145,22 +119,8 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) {
CallSitesForFunc.back().setResolvingCaller(&F);
CallSitesForFunc.back().setCallee(0);
- // 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.
- map<Value*, DSNodeHandle> OldValMap;
- map<const DSNode*, DSNode*> OldNodeMap;
-
- // The clone call may invalidate any of the vectors in the data
- // structure graph. Strip locals and don't copy the list of callers
- DSNodeHandle RetVal = Graph->cloneInto(GI, OldValMap, OldNodeMap,
- /*StripAllocas*/ true);
-
- // Resolve the arguments in the call to the actual values...
- ResolveArguments(Call, FI, OldValMap);
-
- // Handle the return value if present...
- RetVal.mergeWith(Call.getRetVal());
+ // Handle self recursion by resolving the arguments and return value
+ Graph->mergeInGraph(Call, GI, true);
// Erase the entry in the Callees vector
Callees.erase(Callees.begin()+c--);
OpenPOWER on IntegriCloud