aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/DataStructure/BottomUpClosure.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-17 22:16:28 +0000
committerChris Lattner <sabre@nondot.org>2002-11-17 22:16:28 +0000
commitae5f603665c22992f495ba88efab2133d840c4f5 (patch)
tree5c2a2f641eded0c41e335277e2c1799c07b5c2ac /lib/Analysis/DataStructure/BottomUpClosure.cpp
parentdb85e389ae1d11f004a4b415b87e636037c87e44 (diff)
Add MaxSCC statistics
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4722 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/DataStructure/BottomUpClosure.cpp')
-rw-r--r--lib/Analysis/DataStructure/BottomUpClosure.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp
index 435cb1beaf..d8ae1de7be 100644
--- a/lib/Analysis/DataStructure/BottomUpClosure.cpp
+++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp
@@ -13,8 +13,12 @@
#include "Support/Statistic.h"
using std::map;
-static RegisterAnalysis<BUDataStructures>
-X("budatastructure", "Bottom-up Data Structure Analysis Closure");
+namespace {
+ Statistic<> MaxSCC("budatastructure", "Maximum SCC Size in Call Graph");
+
+ RegisterAnalysis<BUDataStructures>
+ X("budatastructure", "Bottom-up Data Structure Analysis Closure");
+}
using namespace DS;
@@ -112,9 +116,11 @@ bool BUDataStructures::run(Module &M) {
// Calculate the graphs for any functions that are unreachable from main...
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isExternal() && DSInfo.find(I) == DSInfo.end()) {
+#ifndef NDEBUG
if (MainFunc)
std::cerr << "*** Function unreachable from main: "
<< I->getName() << "\n";
+#endif
calculateReachableGraphs(I); // Calculate all graphs...
}
return false;
@@ -186,6 +192,8 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
Stack.pop_back();
DSGraph &G = calculateGraph(*F);
+ if (MaxSCC < 1) MaxSCC = 1;
+
// Should we revisit the graph?
if (CallSiteIterator::begin(G) != CallSiteIterator::end(G)) {
ValMap.erase(F);
@@ -211,6 +219,10 @@ unsigned BUDataStructures::calculateGraphs(Function *F,
std::cerr << "Identified SCC #: " << MyID << " of size: "
<< (Stack.end()-FirstInSCC) << "\n";
+ // Compute the Max SCC Size...
+ if (MaxSCC < unsigned(Stack.end()-FirstInSCC))
+ MaxSCC = Stack.end()-FirstInSCC;
+
std::vector<Function*>::iterator I = Stack.end();
do {
--I;
@@ -325,10 +337,20 @@ DSGraph &BUDataStructures::calculateGraph(Function &F) {
DEBUG(std::cerr << " Inlining graph for " << Callee->getName()
<< " in: " << F.getName() << "[" << GI.getGraphSize() << "+"
<< GI.getAuxFunctionCalls().size() << "]\n");
+
+#if 0
+ Graph.writeGraphToFile(std::cerr, "bu_" + F.getName() + "_before_" +
+ Callee->getName());
+#endif
// Handle self recursion by resolving the arguments and return value
Graph.mergeInGraph(CS, GI, DSGraph::StripAllocaBit |
DSGraph::DontCloneCallNodes);
+
+#if 0
+ Graph.writeGraphToFile(std::cerr, "bu_" + F.getName() + "_after_" +
+ Callee->getName());
+#endif
}
}
@@ -400,7 +422,7 @@ DSGraph &BUDataStructures::inlineNonSCCGraphs(Function &F,
DEBUG(std::cerr << " Inlining graph for " << Callee->getName()
<< " in: " << F.getName() << "[" << GI.getGraphSize() << "+"
<< GI.getAuxFunctionCalls().size() << "]\n");
-
+
// Handle self recursion by resolving the arguments and return value
Graph.mergeInGraph(CS, GI, DSGraph::StripAllocaBit |
DSGraph::DontCloneCallNodes);
@@ -423,8 +445,6 @@ DSGraph &BUDataStructures::inlineNonSCCGraphs(Function &F,
<< Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
<< "]\n");
- //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName());
-
return Graph;
}
@@ -518,7 +538,6 @@ DSGraph &BUDataStructures::calculateSCCGraph(Function &F,
DEBUG(std::cerr << " [BU] Done inlining: " << F.getName() << " ["
<< Graph.getGraphSize() << "+" << Graph.getAuxFunctionCalls().size()
<< "]\n");
-
//Graph.writeGraphToFile(std::cerr, "bu_" + F.getName());
return Graph;