aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/TopDownClosure.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-21 19:47:18 +0000
committerChris Lattner <sabre@nondot.org>2002-10-21 19:47:18 +0000
commit198be22cec33455127f151a23a7b68e41de49db9 (patch)
treeaf3a8a2bf5dd55f5570ec9e091c2715444b7ada1 /lib/Analysis/DataStructure/TopDownClosure.cpp
parenteff0da9d33b0067044638b9e53edf462a96e6eab (diff)
- Add "ResolvingCaller" to the CallSite record. This keeps track of which
function was finally able to resolve the function call. Adding this allows the TD pass to actually work right! - Temporarily disable dead node pruning. This will be reenabled soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/TopDownClosure.cpp')
-rw-r--r--lib/Analysis/DataStructure/TopDownClosure.cpp35
1 files changed, 24 insertions, 11 deletions
diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp
index 653d2ca8f6..c573a52c9e 100644
--- a/lib/Analysis/DataStructure/TopDownClosure.cpp
+++ b/lib/Analysis/DataStructure/TopDownClosure.cpp
@@ -20,6 +20,7 @@ Y("tddatastructure", "Top-down Data Structure Analysis Closure");
// our memory... here...
//
void TDDataStructures::releaseMemory() {
+ BUMaps.clear();
for (std::map<const Function*, DSGraph*>::iterator I = DSInfo.begin(),
E = DSInfo.end(); I != E; ++I)
delete I->second;
@@ -76,7 +77,14 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) {
BUDataStructures &BU = getAnalysis<BUDataStructures>();
DSGraph &BUGraph = BU.getDSGraph(F);
- Graph = new DSGraph(BUGraph);
+
+ // Copy the BU graph, keeping a mapping from the BUGraph to the current Graph
+ std::map<const DSNode*, DSNode*> BUNodeMap;
+ Graph = new DSGraph(BUGraph, BUNodeMap);
+
+ // Convert the mapping from a node-to-node map into a node-to-nodehandle map
+ BUMaps[&F].insert(BUNodeMap.begin(), BUNodeMap.end());
+ BUNodeMap.clear(); // We are done with the temporary map.
const std::vector<DSCallSite> *CallSitesP = BU.getCallSites(F);
if (CallSitesP == 0) {
@@ -90,14 +98,19 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) {
DEBUG(std::cerr << " [TD] Inlining 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]; // Copy
- Function &Caller = CallSite.getCaller();
- assert(!Caller.isExternal() && "Externals function cannot 'call'!");
+ const DSCallSite &CallSite = CallSites[c];
+ Function &Caller = *CallSite.getResolvingCaller();
+ assert(&Caller && !Caller.isExternal() &&
+ "Externals function cannot 'call'!");
DEBUG(std::cerr << "\t [TD] Inlining caller #" << c << " '"
<< Caller.getName() << "' into callee: " << F.getName() << "\n");
- if (&Caller != &F) {
+ if (&Caller == &F) {
+ // Self-recursive call: this can happen after a cycle of calls is inlined.
+ ResolveCallSite(*Graph, CallSite);
+ } else {
+
// Recursively compute the graph for the Caller. It should be fully
// resolved except if there is mutual recursion...
//
@@ -111,6 +124,9 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) {
std::map<Value*, DSNodeHandle> OldValMap;
std::map<const DSNode*, DSNode*> OldNodeMap;
+ // Translate call site from having links into the BU graph
+ DSCallSite CallSiteInCG(CallSite, BUMaps[&Caller]);
+
// Clone the Caller's graph into the current graph, keeping
// track of where scalars in the old graph _used_ to point...
// Do this here because it only needs to happens once for each Caller!
@@ -121,20 +137,17 @@ DSGraph &TDDataStructures::calculateGraph(Function &F) {
/*StripAllocas*/ false,
/*CopyCallers*/ true,
/*CopyOrigCalls*/false);
-
- // Make a temporary copy of the call site, and transform the argument node
- // pointers.
- //
+ ResolveCallSite(*Graph, DSCallSite(CallSiteInCG, OldNodeMap));
}
- ResolveCallSite(*Graph, CallSite);
}
// Recompute the Incomplete markers and eliminate unreachable nodes.
+#if 0
Graph->maskIncompleteMarkers();
Graph->markIncompleteNodes(/*markFormals*/ !F.hasInternalLinkage()
/*&& FIXME: NEED TO CHECK IF ALL CALLERS FOUND!*/);
Graph->removeDeadNodes(/*KeepAllGlobals*/ false, /*KeepCalls*/ false);
-
+#endif
DEBUG(std::cerr << " [TD] Done inlining callers for: " << F.getName() << " ["
<< Graph->getGraphSize() << "+" << Graph->getFunctionCalls().size()
<< "]\n");