[llvm-commits] [poolalloc] r116381 - in /poolalloc/trunk: include/dsa/DataStructure.h include/poolalloc/PoolAllocate.h lib/DSA/DSGraph.cpp lib/DSA/EquivClassGraphs.cpp lib/PoolAllocate/PoolAllocate.cpp lib/PoolAllocate/TransformFunctionBody.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Tue Oct 12 17:10:30 PDT 2010
Author: aggarwa4
Date: Tue Oct 12 19:10:30 2010
New Revision: 116381
URL: http://llvm.org/viewvc/llvm-project?rev=116381&view=rev
Log:
Fixed bugs in Call graph construction.
EQBU, TD, and EQTD now preserve CBU results and hence the call graph.
Poolallocation now uses call graph from CBU.
Modified:
poolalloc/trunk/include/dsa/DataStructure.h
poolalloc/trunk/include/poolalloc/PoolAllocate.h
poolalloc/trunk/lib/DSA/DSGraph.cpp
poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp
poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=116381&r1=116380&r2=116381&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Tue Oct 12 19:10:30 2010
@@ -315,6 +315,7 @@
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequired<EntryPointAnalysis>();
AU.addRequired<CompleteBUDataStructures>();
+ AU.addPreserved<CompleteBUDataStructures>();
AU.setPreservesCFG();
}
@@ -368,6 +369,7 @@
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
if (useEQBU) {
AU.addRequired<EquivBUDataStructures>();
+ AU.addPreserved<CompleteBUDataStructures>();
} else {
AU.addRequired<BUDataStructures>();
AU.addPreserved<BUDataStructures>();
Modified: poolalloc/trunk/include/poolalloc/PoolAllocate.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/poolalloc/PoolAllocate.h?rev=116381&r1=116380&r2=116381&view=diff
==============================================================================
--- poolalloc/trunk/include/poolalloc/PoolAllocate.h (original)
+++ poolalloc/trunk/include/poolalloc/PoolAllocate.h Tue Oct 12 19:10:30 2010
@@ -139,6 +139,7 @@
class PoolAllocateGroup : public ModulePass {
protected:
DataStructures *Graphs;
+ DataStructures *CallGraph;
const Type * VoidType;
const Type * Int8Type;
const Type * Int32Type;
@@ -270,6 +271,7 @@
// FIXME: This method is misnamed.
DataStructures &getGraphs() const { return *Graphs; }
+ DSCallGraph getCallGraph() const { return CallGraph->getCallGraph();}
/// getOrigFunctionFromClone - Given a pointer to a function that was cloned
/// from another function, return the original function. If the argument
/// function is not a clone, return null.
Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=116381&r1=116380&r2=116381&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DSGraph.cpp (original)
+++ poolalloc/trunk/lib/DSA/DSGraph.cpp Tue Oct 12 19:10:30 2010
@@ -39,7 +39,7 @@
#define COLLAPSE_ARRAYS_AGGRESSIVELY 0
namespace {
- STATISTIC (NumCallNodesMerged , "Number of call nodes merged");
+ //STATISTIC (NumCallNodesMerged , "Number of call nodes merged");
STATISTIC (NumDNE , "Number of nodes removed by reachability");
STATISTIC (NumTrivialDNE , "Number of nodes trivially removed");
STATISTIC (NumTrivialGlobalDNE, "Number of globals trivially removed");
@@ -785,7 +785,12 @@
&& !N->isNodeCompletelyFolded())
Edge.setTo(0, 0); // Kill the edge!
}
+// TODO: This function removes DS call sites that are identical and need not
+// be inlined again. But the fact that poolallocation, and possibly other
+// clients can query call graph, means we need callee information for all the
+// call sites. And hence, we should not remove them without ever inlining them
+#if 0
static void removeIdenticalCalls(std::list<DSCallSite> &Calls) {
// Remove trivially identical function calls
Calls.sort(); // Sort by callee as primary key!
@@ -937,7 +942,7 @@
if (NumDeleted)
DEBUG(errs() << "Merged " << NumDeleted << " call nodes.\n");
}
-
+#endif
// removeTriviallyDeadNodes - After the graph has been constructed, this method
// removes all unreachable nodes that are created because they got merged with
@@ -1014,9 +1019,10 @@
++NI;
}
}
-
+#if 0
removeIdenticalCalls(FunctionCalls);
removeIdenticalCalls(AuxFunctionCalls);
+#endif
}
// CanReachAliveNodes - Simple graph walker that recursively traverses the graph
Modified: poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp?rev=116381&r1=116380&r2=116381&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp (original)
+++ poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp Tue Oct 12 19:10:30 2010
@@ -40,17 +40,13 @@
// in the program.
//
bool EquivBUDataStructures::runOnModule(Module &M) {
- init(&getAnalysis<CompleteBUDataStructures>(), false, true, false, true);
+ init(&getAnalysis<CompleteBUDataStructures>(), true, true, false, true);
//update the EQ class from indirect calls
- bool result = false;
buildIndirectFunctionSets();
mergeGraphsByGlobalECs();
- result = runOnModuleInternal(M);
-
verifyMerging();
-
- return result;
+ return runOnModuleInternal(M);
}
void
Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=116381&r1=116380&r2=116381&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Tue Oct 12 19:10:30 2010
@@ -118,6 +118,10 @@
if(lie_preserve_passes != LIE_NONE)
AU.addPreserved<EquivBUDataStructures>();
}
+ AU.addRequiredTransitive<CompleteBUDataStructures>();
+ if(lie_preserve_passes != LIE_NONE)
+ AU.addPreserved<CompleteBUDataStructures>();
+
// Preserve the pool information across passes
if (lie_preserve_passes == LIE_PRESERVE_ALL)
@@ -148,6 +152,7 @@
Graphs = &getAnalysis<EQTDDataStructures>();
else
Graphs = &getAnalysis<EquivBUDataStructures>();
+ CallGraph = &getAnalysis<CompleteBUDataStructures>();
//
// Get the heuristic pass and then tell it who we are.
Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=116381&r1=116380&r2=116381&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Tue Oct 12 19:10:30 2010
@@ -874,7 +874,7 @@
// of pools possible and prevents us from eliding a pool because we're
// examining a target that doesn't need it.
//
- const DSCallGraph & callGraph = Graphs.getCallGraph();
+ const DSCallGraph & callGraph = PAInfo.getCallGraph();
unsigned maxArgsWithNodes = 0;
DSCallGraph::callee_iterator I = callGraph.callee_begin(OrigInst);
for (; I != callGraph.callee_end(OrigInst); ++I) {
@@ -883,12 +883,12 @@
// it should be an original function.
//
FuncInfo *CFI = PAInfo.getFuncInfo(**I);
-
+ assert(CFI && "Func Info not found");
//
// If this target takes more DSNodes than the last one we found, then
// make *this* target our canonical target.
//
- if (CFI->ArgNodes.size() > maxArgsWithNodes) {
+ if (CFI->ArgNodes.size() >= maxArgsWithNodes) {
maxArgsWithNodes = CFI->ArgNodes.size();
CF = *I;
}
@@ -906,7 +906,10 @@
assert (d && "No DSNode!\n");
std::vector<const Function*> g;
d->addFullFunctionList(g);
-
+
+ if(!(d->isIncompleteNode()) && !(d->isExternalNode())) {
+ //if(!(d->isIncompleteNode()) && !(d->isExternalNode()) && !(d->isCollapsedNode())) {
+
//
// Perform some consistency checks on the callees.
//
@@ -918,10 +921,11 @@
// same DSGraph, so it doesn't matter which one we use as long as we use
// a function that *has* a DSGraph.
//
- for (unsigned index = 0; index < g.size(); ++index) {
- if (Graphs.hasDSGraph (*(g[index]))) {
- CF = g[index];
- break;
+ for (unsigned index = 0; index < g.size(); ++index) {
+ if (Graphs.hasDSGraph (*(g[index]))) {
+ CF = g[index];
+ break;
+ }
}
}
}
@@ -951,14 +955,14 @@
#ifndef NDEBUG
// Verify that all potential callees at call site have the same DS graph.
- DSCallGraph::callee_iterator E = Graphs.getCallGraph().callee_end(OrigInst);
+ /*DSCallGraph::callee_iterator E = PAInfo.getCallGraph().callee_end(OrigInst);
for (; I != E; ++I) {
const Function * F = *I;
assert (F);
if (!(F)->isDeclaration())
assert(CalleeGraph == Graphs.getDSGraph(**I) &&
"Callees at call site do not have a common graph!");
- }
+ }*/
#endif
// Find the DS nodes for the arguments that need to be added, if any.
More information about the llvm-commits
mailing list