[llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Local.cpp Printer.cpp TopDownClosure.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Nov 9 15:13:01 PST 2002
Changes in directory llvm/lib/Analysis/DataStructure:
BottomUpClosure.cpp updated: 1.38 -> 1.39
Local.cpp updated: 1.35 -> 1.36
Printer.cpp updated: 1.36 -> 1.37
TopDownClosure.cpp updated: 1.27 -> 1.28
---
Log message:
Add globals graphs to all three passes
---
Diffs of the changes:
Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.38 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.39
--- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.38 Sat Nov 9 15:00:47 2002
+++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Sat Nov 9 15:12:06 2002
@@ -18,6 +18,18 @@
using namespace DS;
+// run - Calculate the bottom up data structure graphs for each function in the
+// program.
+//
+bool BUDataStructures::run(Module &M) {
+ GlobalsGraph = new DSGraph();
+
+ // Simply calculate the graphs for each function...
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
+ if (!I->isExternal())
+ calculateGraph(*I);
+ return false;
+}
// releaseMemory - If the pass pipeline is done with this pass, we can release
// our memory... here...
@@ -30,17 +42,8 @@
// Empty map so next time memory is released, data structures are not
// re-deleted.
DSInfo.clear();
-}
-
-// run - Calculate the bottom up data structure graphs for each function in the
-// program.
-//
-bool BUDataStructures::run(Module &M) {
- // Simply calculate the graphs for each function...
- for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
- if (!I->isExternal())
- calculateGraph(*I);
- return false;
+ delete GlobalsGraph;
+ GlobalsGraph = 0;
}
DSGraph &BUDataStructures::calculateGraph(Function &F) {
@@ -52,6 +55,7 @@
// Copy the local version into DSInfo...
Graph = new DSGraph(getAnalysis<LocalDataStructures>().getDSGraph(F));
+ Graph->setGlobalsGraph(GlobalsGraph);
#if 0
// Populate the GlobalsGraph with globals from this one.
Index: llvm/lib/Analysis/DataStructure/Local.cpp
diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.35 llvm/lib/Analysis/DataStructure/Local.cpp:1.36
--- llvm/lib/Analysis/DataStructure/Local.cpp:1.35 Sat Nov 9 15:00:47 2002
+++ llvm/lib/Analysis/DataStructure/Local.cpp Sat Nov 9 15:12:06 2002
@@ -409,6 +409,16 @@
// LocalDataStructures Implementation
//===----------------------------------------------------------------------===//
+bool LocalDataStructures::run(Module &M) {
+ GlobalsGraph = new DSGraph();
+
+ // Calculate all of the graphs...
+ for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
+ if (!I->isExternal())
+ DSInfo.insert(std::make_pair(I, new DSGraph(*I, GlobalsGraph)));
+ return false;
+}
+
// releaseMemory - If the pass pipeline is done with this pass, we can release
// our memory... here...
//
@@ -422,14 +432,4 @@
DSInfo.clear();
delete GlobalsGraph;
GlobalsGraph = 0;
-}
-
-bool LocalDataStructures::run(Module &M) {
- GlobalsGraph = new DSGraph();
-
- // Calculate all of the graphs...
- for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
- if (!I->isExternal())
- DSInfo.insert(std::make_pair(I, new DSGraph(*I, GlobalsGraph)));
- return false;
}
Index: llvm/lib/Analysis/DataStructure/Printer.cpp
diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.36 llvm/lib/Analysis/DataStructure/Printer.cpp:1.37
--- llvm/lib/Analysis/DataStructure/Printer.cpp:1.36 Thu Nov 7 19:21:07 2002
+++ llvm/lib/Analysis/DataStructure/Printer.cpp Sat Nov 9 15:12:06 2002
@@ -181,6 +181,16 @@
}
}
+ DSGraph &GG = C.getGlobalsGraph();
+ TotalNumNodes += GG.getGraphSize();
+ TotalCallNodes += GG.getFunctionCalls().size();
+ if (OnlyPrintMain) {
+ GG.writeGraphToFile(O, Prefix+"GlobalsGraph");
+ } else {
+ O << "Skipped Writing '" << Prefix << "GlobalsGraph.dot'... ["
+ << GG.getGraphSize() << "+" << GG.getFunctionCalls().size() << "]\n";
+ }
+
O << "\nGraphs contain [" << TotalNumNodes << "+" << TotalCallNodes
<< "] nodes total" << std::endl;
}
Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp
diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.27 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.28
--- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.27 Sat Nov 9 15:00:47 2002
+++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Sat Nov 9 15:12:06 2002
@@ -16,24 +16,12 @@
static RegisterAnalysis<TDDataStructures>
Y("tddatastructure", "Top-down Data Structure Analysis Closure");
-// releaseMemory - If the pass pipeline is done with this pass, we can release
-// our memory... here...
-//
-void TDDataStructures::releaseMemory() {
- for (std::map<const Function*, DSGraph*>::iterator I = DSInfo.begin(),
- E = DSInfo.end(); I != E; ++I)
- delete I->second;
-
- // Empty map so next time memory is released, data structures are not
- // re-deleted.
- DSInfo.clear();
-}
-
// run - Calculate the top down data structure graphs for each function in the
// program.
//
bool TDDataStructures::run(Module &M) {
BUDataStructures &BU = getAnalysis<BUDataStructures>();
+ GlobalsGraph = new DSGraph();
// Calculate top-down from main...
if (Function *F = M.getMainFunction())
@@ -43,9 +31,26 @@
for (Module::reverse_iterator I = M.rbegin(), E = M.rend(); I != E; ++I)
if (!I->isExternal())
calculateGraph(*I);
+
+ GraphDone.clear(); // Free temporary memory...
return false;
}
+// releaseMemory - If the pass pipeline is done with this pass, we can release
+// our memory... here...
+//
+void TDDataStructures::releaseMemory() {
+ for (std::map<const Function*, DSGraph*>::iterator I = DSInfo.begin(),
+ E = DSInfo.end(); I != E; ++I)
+ delete I->second;
+
+ // Empty map so next time memory is released, data structures are not
+ // re-deleted.
+ DSInfo.clear();
+ delete GlobalsGraph;
+ GlobalsGraph = 0;
+}
+
/// ResolveCallSite - This method is used to link the actual arguments together
/// with the formal arguments for a function call in the top-down closure. This
/// method assumes that the call site arguments have been mapped into nodes
@@ -77,6 +82,7 @@
if (G == 0) { // Not created yet? Clone BU graph...
G = new DSGraph(getAnalysis<BUDataStructures>().getDSGraph(F));
G->getAuxFunctionCalls().clear();
+ G->setGlobalsGraph(GlobalsGraph);
}
return *G;
}
More information about the llvm-commits
mailing list