[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp DataStructure.cpp TopDownClosure.cpp
Chris Lattner
lattner at cs.uiuc.edu
Thu Oct 17 15:11:01 PDT 2002
Changes in directory llvm/lib/Analysis/DataStructure:
BottomUpClosure.cpp updated: 1.16 -> 1.17
DataStructure.cpp updated: 1.23 -> 1.24
TopDownClosure.cpp updated: 1.7 -> 1.8
---
Log message:
* Make the DSGraph cloner automatically merge global nodes
* BUClosure doesn't have to worry about global nodes
* TDClosure now works with global nodes
* Reenable DNE on TD pass, now that globals work right
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.16 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.17
--- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.16 Wed Oct 16 23:58:10 2002
+++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Thu Oct 17 15:09:52 2002
@@ -71,35 +71,6 @@
}
}
-// MergeGlobalNodes - Merge all existing global nodes with globals
-// inlined from the callee or with globals from the GlobalsGraph.
-//
-static void MergeGlobalNodes(DSGraph &Graph,
- map<Value*, DSNodeHandle> &OldValMap) {
- map<Value*, DSNodeHandle> &ValMap = Graph.getValueMap();
- for (map<Value*, DSNodeHandle>::iterator I = ValMap.begin(), E = ValMap.end();
- I != E; ++I)
- if (GlobalValue *GV = dyn_cast<GlobalValue>(I->first)) {
- map<Value*, DSNodeHandle>::iterator NHI = OldValMap.find(GV);
- if (NHI != OldValMap.end()) // was it inlined from the callee?
- I->second.mergeWith(NHI->second);
-#if 0
- else // get it from the GlobalsGraph
- I->second.mergeWith(Graph.cloneGlobalInto(GV));
-#endif
- }
-
- // Add unused inlined global nodes into the value map
- for (map<Value*, DSNodeHandle>::iterator I = OldValMap.begin(),
- E = OldValMap.end(); I != E; ++I)
- if (isa<GlobalValue>(I->first)) {
- DSNodeHandle &NH = ValMap[I->first]; // If global is not in ValMap...
- if (NH.getNode() == 0)
- NH = I->second; // Add the one just inlined.
- }
-
-}
-
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.
@@ -190,11 +161,6 @@
if (Call[0].getNode()) // Handle the return value if present
RetVal.mergeWith(Call[0]);
-
- // Merge global value nodes in the inlined graph with the global
- // value nodes in the current graph if there are duplicates.
- //
- MergeGlobalNodes(*Graph, OldValMap);
// Erase the entry in the Callees vector
Callees.erase(Callees.begin()+c--);
Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp
diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.23 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.24
--- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.23 Wed Oct 16 23:57:43 2002
+++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Thu Oct 17 15:09:52 2002
@@ -439,13 +439,24 @@
for (unsigned i = FN, e = Nodes.size(); i != e; ++i)
Nodes[i]->NodeType &= ~StripBits;
- // Copy the value map...
+ // Copy the value map... and merge all of the global nodes...
for (std::map<Value*, DSNodeHandle>::const_iterator I = G.ValueMap.begin(),
- E = G.ValueMap.end(); I != E; ++I)
- OldValMap[I->first] = DSNodeHandle(OldNodeMap[I->second.getNode()],
- I->second.getOffset());
+ E = G.ValueMap.end(); I != E; ++I) {
+ DSNodeHandle &H = OldValMap[I->first];
+ H = DSNodeHandle(OldNodeMap[I->second.getNode()], I->second.getOffset());
+
+ if (isa<GlobalValue>(I->first)) { // Is this a global?
+ std::map<Value*, DSNodeHandle>::iterator GVI = ValueMap.find(I->first);
+ if (GVI != ValueMap.end()) { // Is the global value in this fun already?
+ GVI->second.mergeWith(H);
+ } else {
+ ValueMap[I->first] = H; // Add global pointer to this graph
+ }
+ }
+ }
// Copy the function calls list...
CopyFunctionCallsList(G.FunctionCalls, FunctionCalls, OldNodeMap);
+
// Return the returned node pointer...
return DSNodeHandle(OldNodeMap[G.RetNode.getNode()], G.RetNode.getOffset());
Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.7 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.8
--- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.7 Wed Oct 16 23:57:28 2002
+++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Thu Oct 17 15:09:52 2002
@@ -165,13 +165,6 @@
}
ResolveCallSite(*Graph, CallSite);
-
-#if 0
- // If its not a self-recursive call, merge global nodes in the inlined
- // graph with the corresponding global nodes in the current graph
- if (&caller != &callee)
- MergeGlobalNodes(calleeGraph, OldValMap);
-#endif
}
}
@@ -180,9 +173,7 @@
Graph->maskIncompleteMarkers();
Graph->markIncompleteNodes(/*markFormals*/ !F.hasInternalLinkage()
/*&& FIXME: NEED TO CHECK IF ALL CALLERS FOUND!*/);
-#if 0
Graph->removeDeadNodes(/*KeepAllGlobals*/ false, /*KeepCalls*/ false);
-#endif
DEBUG(std::cerr << " [TD] Done inlining callers for: " << F.getName() << " ["
<< Graph->getGraphSize() << "+" << Graph->getFunctionCalls().size()
More information about the llvm-commits
mailing list