Add MaxSCC statistics

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4722 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2002-11-17 22:16:28 +00:00
parent db85e389ae
commit ae5f603665

View File

@ -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;