[llvm-commits] [poolalloc] r118191 - in /poolalloc/trunk: include/dsa/DSGraph.h include/dsa/DataStructure.h lib/DSA/BottomUpClosure.cpp lib/DSA/DSGraph.cpp lib/DSA/DataStructure.cpp lib/DSA/Local.cpp lib/PoolAllocate/TransformFunctionBody.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Wed Nov 3 13:13:13 PDT 2010
Author: aggarwa4
Date: Wed Nov 3 15:13:13 2010
New Revision: 118191
URL: http://llvm.org/viewvc/llvm-project?rev=118191&view=rev
Log:
The call graph, now reports the conservatively correct, set of
all address taken functions, for any unresolved call site.
Fixes 252.eon
Modified:
poolalloc/trunk/include/dsa/DSGraph.h
poolalloc/trunk/include/dsa/DataStructure.h
poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
poolalloc/trunk/lib/DSA/DSGraph.cpp
poolalloc/trunk/lib/DSA/DataStructure.cpp
poolalloc/trunk/lib/DSA/Local.cpp
poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
Modified: poolalloc/trunk/include/dsa/DSGraph.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSGraph.h?rev=118191&r1=118190&r2=118191&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSGraph.h (original)
+++ poolalloc/trunk/include/dsa/DSGraph.h Wed Nov 3 15:13:13 2010
@@ -345,7 +345,7 @@
// addAuxFunctionCall - Add a call site to the AuxFunctionCallList
void addAuxFunctionCall(DSCallSite D) { AuxFunctionCalls.push_front(D); }
- void buildCallGraph(DSCallGraph& DCG, bool filter) const;
+ void buildCallGraph(DSCallGraph& DCG, std::vector<const Function*> &GlobalFunctionList, bool filter) const;
/// removeFunction - Specify that all call sites to the function have been
/// fully specified by a pass such as StdLibPass.
Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=118191&r1=118190&r2=118191&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Wed Nov 3 15:13:13 2010
@@ -80,6 +80,9 @@
// Callgraph, as computed so far
DSCallGraph callgraph;
+ // List of all address taken functions.
+ // This is used as target, of indirect calls for any indirect call site with // incomplete callee node.
+ std::vector<const Function*> GlobalFunctionList;
void init(DataStructures* D, bool clone, bool useAuxCalls, bool copyGlobalAuxCalls, bool resetAux);
void init(TargetData* T);
@@ -87,6 +90,8 @@
void formGlobalECs();
void restoreCorrectCallGraph();
+
+ void formGlobalFunctionList();
DataStructures(intptr_t id, const char* name)
: ModulePass(id), TD(0), GraphSource(0), printname(name), GlobalsGraph(0) {
Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=118191&r1=118190&r2=118191&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Wed Nov 3 15:13:13 2010
@@ -150,7 +150,7 @@
if (!(F->isDeclaration())){
DSGraph *Graph = getOrCreateGraph(F);
cloneGlobalsInto(Graph);
- Graph->buildCallGraph(callgraph, filterCallees);
+ Graph->buildCallGraph(callgraph, GlobalFunctionList, filterCallees);
Graph->maskIncompleteMarkers();
Graph->markIncompleteNodes(DSGraph::MarkFormalArgs |
DSGraph::IgnoreGlobals);
@@ -840,7 +840,7 @@
// Update the callgraph with the new information that we have gleaned.
// NOTE : This must be called before removeDeadNodes, so that no
// information is lost due to deletion of DSCallNodes.
- Graph->buildCallGraph(callgraph,filterCallees);
+ Graph->buildCallGraph(callgraph,GlobalFunctionList, filterCallees);
// Delete dead nodes. Treat globals that are unreachable but that can
// reach live nodes as live.
Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=118191&r1=118190&r2=118191&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DSGraph.cpp (original)
+++ poolalloc/trunk/lib/DSA/DSGraph.cpp Wed Nov 3 15:13:13 2010
@@ -480,7 +480,7 @@
AuxCallToCopy.push_back(&*I);
// else if (I->isIndirectCall()){
// //If the call node doesn't have any callees, clone it
-// std::vector< Function *> List;
+// std::vector< const Function *> List;
// I->getCalleeNode()->addFullFunctionList(List);
// if (!List.size())
// AuxCallToCopy.push_back(&*I);
@@ -1601,10 +1601,14 @@
// of function calls that can be inferred from the unresolved call sites
// within the DSGraph.
//
+// The parameter GlobalFunctionList, is a list of all the address taken
+// functions in the module. This is used as the list of targets when a callee
+// node is Incomplete.
+//
// The parameter 'filter' determines if we should attempt to prune callees
// that are illegal to be called from the callsite.
//
-void DSGraph::buildCallGraph(DSCallGraph& DCG, bool filter) const {
+void DSGraph::buildCallGraph(DSCallGraph& DCG, std::vector<const Function*>& GlobalFunctionList, bool filter) const {
//
// Get the list of unresolved call sites.
//
@@ -1624,7 +1628,11 @@
//
// Get the list of known targets of this function.
//
- ii->getCalleeNode()->addFullFunctionList(MaybeTargets);
+ if(ii->getCalleeNode()->isIncompleteNode()) {
+ MaybeTargets.assign(GlobalFunctionList.begin(), GlobalFunctionList.end());
+ } else {
+ ii->getCalleeNode()->addFullFunctionList(MaybeTargets);
+ }
//
// Ensure that the call graph at least knows about (has a record of) this
Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=118191&r1=118190&r2=118191&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Wed Nov 3 15:13:13 2010
@@ -1302,6 +1302,26 @@
return G;
}
+void DataStructures::formGlobalFunctionList() {
+ std::vector<const Function*> List;
+ DSScalarMap &SN = GlobalsGraph->getScalarMap();
+ EquivalenceClasses<const GlobalValue*> &EC = GlobalsGraph->getGlobalECs();
+ for (DSScalarMap::global_iterator I = SN.global_begin(), E = SN.global_end(); I != E; ++I) {
+ EquivalenceClasses<const GlobalValue*>::iterator ECI = EC.findValue(*I);
+ if (ECI == EC.end()) {
+ if (const Function *F = dyn_cast<Function>(*I))
+ List.push_back(F);
+ } else {
+ for (EquivalenceClasses<const GlobalValue*>::member_iterator MI =
+ EC.member_begin(ECI), ME = EC.member_end(); MI != ME; ++MI){
+ if (const Function *F = dyn_cast<Function>(*MI))
+ List.push_back(F);
+ }
+ }
+ }
+ GlobalFunctionList.swap(List);
+}
+
void DataStructures::formGlobalECs() {
// Grow the equivalence classes for the globals to include anything that we
@@ -1412,6 +1432,7 @@
TD = D->TD;
TypeSS = D->TypeSS;
callgraph = D->callgraph;
+ GlobalFunctionList = D->GlobalFunctionList;
GlobalECs = D->getGlobalECs();
GlobalsGraph = new DSGraph(D->getGlobalsGraph(), GlobalECs, *TypeSS,
copyGlobalAuxCalls? DSGraph::CloneAuxCallNodes
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=118191&r1=118190&r2=118191&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Wed Nov 3 15:13:13 2010
@@ -1253,6 +1253,11 @@
// Next step, iterate through the nodes in the globals graph, unioning
// together the globals into equivalence classes.
formGlobalECs();
+
+ // Iterate through the address taken functions in the globals graph,
+ // collecting them in a list, to be used as target for call sites that
+ // cant be resolved.
+ formGlobalFunctionList();
// Calculate all of the graphs...
for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
@@ -1263,7 +1268,7 @@
setDSGraph(*I, G);
propagateUnknownFlag(G);
callgraph.insureEntry(I);
- G->buildCallGraph(callgraph, true);
+ G->buildCallGraph(callgraph, GlobalFunctionList, true);
}
GlobalsGraph->removeTriviallyDeadNodes();
Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=118191&r1=118190&r2=118191&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Wed Nov 3 15:13:13 2010
@@ -917,8 +917,10 @@
// Get the information for this function. Since this is coming from DSA,
// it should be an original function.
//
+ // This call site calls a function, that is not defined in this module
+ if (!(Graphs.hasDSGraph(**I))) return;
+ // For all other cases Func Info must exist.
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.
@@ -928,14 +930,16 @@
CF = *I;
}
}
-
+
+ // Assuming the call graph is always correct. And if the call graph reports,
+ // no callees, we can assume that it is right.
//
// If we didn't find the callee in the constructed call graph, try
// checking in the DSNode itself.
// This isn't ideal as it means that this call site didn't have inlining
// happen.
//
- if (!CF) {
+ /*if (!CF) {
DSGraph* dg = Graphs.getDSGraph(*OrigInst->getParent()->getParent());
DSNode* d = dg->getNodeForValue(OrigInst->getOperand(0)).getNode();
assert (d && "No DSNode!\n");
@@ -961,7 +965,7 @@
break;
}
}
- }
+ }*/
//
// If we still haven't been able to find a target function of the call site
More information about the llvm-commits
mailing list