[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp TopDownClosure.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 2 18:43:01 PDT 2003
Changes in directory llvm/lib/Analysis/DataStructure:
BottomUpClosure.cpp updated: 1.60 -> 1.61
TopDownClosure.cpp updated: 1.49 -> 1.50
---
Log message:
Fix how we are handling unreachable functions. This DRAMATICALLY improves efficiency
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.60 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.61
--- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.60 Wed Jul 2 15:24:42 2003
+++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Wed Jul 2 18:42:48 2003
@@ -15,6 +15,7 @@
namespace {
Statistic<> MaxSCC("budatastructure", "Maximum SCC Size in Call Graph");
Statistic<> NumBUInlines("budatastructures", "Number of graphs inlined");
+ Statistic<> NumCallEdges("budatastructures", "Number of 'actual' call edges");
RegisterAnalysis<BUDataStructures>
X("budatastructure", "Bottom-up Data Structure Analysis");
@@ -44,6 +45,8 @@
#endif
calculateReachableGraphs(I); // Calculate all graphs...
}
+
+ NumCallEdges += ActualCallees.size();
return false;
}
Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.49 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.50
--- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.49 Wed Jul 2 14:49:11 2003
+++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Wed Jul 2 18:42:48 2003
@@ -43,38 +43,31 @@
if (!FunctionHasCompleteArguments(*I))
ArgsRemainIncomplete.insert(I);
+ // We want to traverse the call graph in reverse post-order. To do this, we
+ // calculate a post-order traversal, then reverse it.
+ hash_set<DSGraph*> VisitedGraph;
+ std::vector<DSGraph*> PostOrder;
+ const BUDataStructures::ActualCalleesTy &ActualCallees =
+ getAnalysis<BUDataStructures>().getActualCallees();
+
// Calculate top-down from main...
if (Function *F = M.getMainFunction())
- calculateGraphFrom(*F);
+ ComputePostOrder(*F, VisitedGraph, PostOrder, ActualCallees);
// Next calculate the graphs for each function unreachable function...
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
- if (!I->isExternal() && !DSInfo.count(I))
- calculateGraphFrom(*I);
+ ComputePostOrder(*I, VisitedGraph, PostOrder, ActualCallees);
- ArgsRemainIncomplete.clear();
- return false;
-}
+ VisitedGraph.clear(); // Release memory!
-// releaseMemory - If the pass pipeline is done with this pass, we can release
-// our memory... here...
-//
-// FIXME: This should be releaseMemory and will work fine, except that LoadVN
-// has no way to extend the lifetime of the pass, which screws up ds-aa.
-//
-void TDDataStructures::releaseMyMemory() {
- for (hash_map<Function*, DSGraph*>::iterator I = DSInfo.begin(),
- E = DSInfo.end(); I != E; ++I) {
- I->second->getReturnNodes().erase(I->first);
- if (I->second->getReturnNodes().empty())
- delete I->second;
+ // Visit each of the graphs in reverse post-order now!
+ while (!PostOrder.empty()) {
+ inlineGraphIntoCallees(*PostOrder.back());
+ PostOrder.pop_back();
}
- // Empty map so next time memory is released, data structures are not
- // re-deleted.
- DSInfo.clear();
- delete GlobalsGraph;
- GlobalsGraph = 0;
+ ArgsRemainIncomplete.clear();
+ return false;
}
@@ -116,22 +109,28 @@
-void TDDataStructures::calculateGraphFrom(Function &F) {
- // We want to traverse the call graph in reverse post-order. To do this, we
- // calculate a post-order traversal, then reverse it.
- hash_set<DSGraph*> VisitedGraph;
- std::vector<DSGraph*> PostOrder;
- ComputePostOrder(F, VisitedGraph, PostOrder,
- getAnalysis<BUDataStructures>().getActualCallees());
- VisitedGraph.clear(); // Release memory!
- // Visit each of the graphs in reverse post-order now!
- while (!PostOrder.empty()) {
- inlineGraphIntoCallees(*PostOrder.back());
- PostOrder.pop_back();
+
+// releaseMemory - If the pass pipeline is done with this pass, we can release
+// our memory... here...
+//
+// FIXME: This should be releaseMemory and will work fine, except that LoadVN
+// has no way to extend the lifetime of the pass, which screws up ds-aa.
+//
+void TDDataStructures::releaseMyMemory() {
+ for (hash_map<Function*, DSGraph*>::iterator I = DSInfo.begin(),
+ E = DSInfo.end(); I != E; ++I) {
+ I->second->getReturnNodes().erase(I->first);
+ if (I->second->getReturnNodes().empty())
+ delete I->second;
}
-}
+ // Empty map so next time memory is released, data structures are not
+ // re-deleted.
+ DSInfo.clear();
+ delete GlobalsGraph;
+ GlobalsGraph = 0;
+}
void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) {
// Recompute the Incomplete markers and eliminate unreachable nodes.
More information about the llvm-commits
mailing list