[llvm-commits] [poolalloc] r122344 - in /poolalloc/trunk: include/dsa/DSGraph.h lib/DSA/BottomUpClosure.cpp lib/DSA/CompleteBottomUp.cpp lib/DSA/DSGraph.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Dec 21 09:13:02 PST 2010


Author: aggarwa4
Date: Tue Dec 21 11:13:02 2010
New Revision: 122344

URL: http://llvm.org/viewvc/llvm-project?rev=122344&view=rev
Log:
1. DSCallGraph should only default to adding the whole
GlobalFunction list(all address taken functions) once
we have finished BU. 
2. We do not need to build SCCs in BU. Push to CBU.


Modified:
    poolalloc/trunk/include/dsa/DSGraph.h
    poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
    poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp
    poolalloc/trunk/lib/DSA/DSGraph.cpp

Modified: poolalloc/trunk/include/dsa/DSGraph.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSGraph.h?rev=122344&r1=122343&r2=122344&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSGraph.h (original)
+++ poolalloc/trunk/include/dsa/DSGraph.h Tue Dec 21 11:13:02 2010
@@ -346,6 +346,7 @@
   void addAuxFunctionCall(DSCallSite D) { AuxFunctionCalls.push_front(D); }
 
   void buildCallGraph(DSCallGraph& DCG, std::vector<const Function*> &GlobalFunctionList, bool filter) const;
+  void buildCompleteCallGraph(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/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=122344&r1=122343&r2=122344&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Tue Dec 21 11:13:02 2010
@@ -59,12 +59,6 @@
 bool BUDataStructures::runOnModuleInternal(Module& M) {
 
   //
-  // Put the callgraph into canonical form by finding SCCs.
-  //
-  callgraph.buildSCCs();
-  callgraph.buildRoots();
-
-  //
   // Make sure we have a DSGraph for all declared functions in the Module.
   // While we may not need them in this DSA pass, a later DSA pass may ask us
   // for their DSGraphs, and we want to have them if asked.
@@ -121,13 +115,6 @@
 
   NumCallEdges += callgraph.size();
 
-  //
-  // Put the callgraph into canonical form by finding SCCs.  It has been
-  // updated since we did this last.
-  //
-  callgraph.buildSCCs();
-  callgraph.buildRoots();
-
   return false;
 }
 
@@ -615,7 +602,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,GlobalFunctionList, 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/CompleteBottomUp.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp?rev=122344&r1=122343&r2=122344&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp (original)
+++ poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp Tue Dec 21 11:13:02 2010
@@ -51,9 +51,13 @@
   // DSgraphs for all the functions.
 
   for (Module::iterator F = M.begin(); F != M.end(); ++F) {
-    if (!(F->isDeclaration()))
-      getOrCreateGraph(F);
+    if (!(F->isDeclaration())){
+      DSGraph *Graph = getOrCreateGraph(F);
+      Graph->buildCompleteCallGraph(callgraph, GlobalFunctionList, filterCallees);
+    }
   }
+  callgraph.buildSCCs();
+  callgraph.buildRoots();
 
   buildIndirectFunctionSets();
   formGlobalECs();
@@ -80,6 +84,10 @@
   // Do bottom-up propagation.
   //
   bool modified = runOnModuleInternal(M);
+  
+  callgraph.buildSCCs();
+  callgraph.buildRoots();
+  
   return modified;
 }
 

Modified: poolalloc/trunk/lib/DSA/DSGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSGraph.cpp?rev=122344&r1=122343&r2=122344&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DSGraph.cpp (original)
+++ poolalloc/trunk/lib/DSA/DSGraph.cpp Tue Dec 21 11:13:02 2010
@@ -1626,14 +1626,12 @@
       CallSite CS = ii->getCallSite();
       std::vector<const Function*> MaybeTargets;
 
+      if(ii->getCalleeNode()->isIncompleteNode())
+        continue;
       //
       // Get the list of known targets of this function.
       //
-      if(ii->getCalleeNode()->isIncompleteNode()) {
-        MaybeTargets.assign(GlobalFunctionList.begin(), GlobalFunctionList.end());
-      } else {
-        ii->getCalleeNode()->addFullFunctionList(MaybeTargets);
-      }
+      ii->getCalleeNode()->addFullFunctionList(MaybeTargets);
 
       //
       // Ensure that the call graph at least knows about (has a record of) this
@@ -1663,3 +1661,42 @@
     }
   }
 }
+void DSGraph::buildCompleteCallGraph(DSCallGraph& DCG, std::vector<const Function*>& GlobalFunctionList, bool filter) const {
+  //
+  // Get the list of unresolved call sites.
+  //
+  const std::list<DSCallSite>& Calls = getAuxFunctionCalls();
+  for (std::list<DSCallSite>::const_iterator ii = Calls.begin(),
+                                             ee = Calls.end();
+       ii != ee; ++ii) {
+    
+    if (ii->isDirectCall()) continue;
+    if (ii->getCalleeNode()->isCompleteNode()) continue;
+    CallSite CS = ii->getCallSite();
+    if (DCG.callee_size(CS) != 0) continue;
+    std::vector<const Function*> MaybeTargets;
+    MaybeTargets.assign(GlobalFunctionList.begin(), GlobalFunctionList.end());
+
+    DCG.insert(CS, 0);
+    //
+    // Add to the call graph only function targets that have well-defined
+    // behavior using LLVM semantics.
+    //
+    for (std::vector<const Function*>::iterator Fi = MaybeTargets.begin(),
+         Fe = MaybeTargets.end(); Fi != Fe; ++Fi)
+      if (!filter || functionIsCallable(CS, *Fi))
+        DCG.insert(CS, *Fi);
+      else
+        ++NumFiltered;
+    for (unsigned i = 0; i < ii->getNumMappedSites(); i++) {
+      CallSite MCS = ii->getMappedCallSite(i);
+      for (std::vector<const Function*>::iterator Fi = MaybeTargets.begin(),
+            Fe = MaybeTargets.end(); Fi != Fe; ++Fi){
+        if (!filter || functionIsCallable(MCS, *Fi))
+          DCG.insert(MCS, *Fi);
+        else
+          ++NumFiltered;
+      }
+     }
+  }
+}





More information about the llvm-commits mailing list