[llvm-commits] [poolalloc] r120781 - in /poolalloc/trunk: include/dsa/DSCallGraph.h lib/DSA/CompleteBottomUp.cpp lib/PoolAllocate/TransformFunctionBody.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Thu Dec 2 17:58:27 PST 2010


Author: aggarwa4
Date: Thu Dec  2 19:58:27 2010
New Revision: 120781

URL: http://llvm.org/viewvc/llvm-project?rev=120781&view=rev
Log:
Handle call graph correctly.
In CBU, we must take care that any call site can
call functions in its own SCC that are address taken
and must merge those too.
In Poolalloc, we must check to only ask for graphs
for functions that are actually address taken because
the rest are not merged.

Modified:
    poolalloc/trunk/include/dsa/DSCallGraph.h
    poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp
    poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp

Modified: poolalloc/trunk/include/dsa/DSCallGraph.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSCallGraph.h?rev=120781&r1=120780&r2=120781&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSCallGraph.h (original)
+++ poolalloc/trunk/include/dsa/DSCallGraph.h Thu Dec  2 19:58:27 2010
@@ -142,7 +142,7 @@
     return SCCs.member_end();
   }
   
-  const llvm::Function* sccLeader(llvm::Function*F) const {
+  const llvm::Function* sccLeader(const llvm::Function*F) const {
     return SCCs.getLeaderValue(F);
   }
   unsigned callee_size(llvm::CallSite CS) const {

Modified: poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp?rev=120781&r1=120780&r2=120781&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp (original)
+++ poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp Thu Dec  2 19:58:27 2010
@@ -19,6 +19,7 @@
 #include "llvm/Module.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/FormattedStream.h"
 using namespace llvm;
 
 namespace {
@@ -150,6 +151,23 @@
     // this code is careful to handle callees not existing in the globals graph
     // In other words what we have here should be correct, but might be overkill
     // that we can trim down later as needed.
+    
+    DSNodeHandle calleesNH;
+   
+    // When we build SCCs we remove any calls that are to functions in the 
+    // same SCC. Hence, for every indirect call site we must assume that it
+    // might call functions in its function's SCC that are address taken.
+    const Function *F1 = (*ii).getInstruction()->getParent()->getParent();
+    F1 = callgraph.sccLeader(&*F1);
+
+    DSCallGraph::scc_iterator sccii = callgraph.scc_begin(F1),
+                                sccee = callgraph.scc_end(F1);
+    for(;sccii != sccee; ++sccii) {
+      DSGraph::ScalarMapTy::const_iterator I = SM.find(SM.getLeaderForGlobal(*sccii));
+      if (I != SM.end()) {
+        calleesNH.mergeWith(I->second);
+      }
+    }
 
     DSCallGraph::callee_iterator csi = callgraph.callee_begin(*ii),
             cse = callgraph.callee_end(*ii);
@@ -169,14 +187,13 @@
     // be merged by CBU.
 
     // This NH starts off empty, but ends up merging them all together
-    DSNodeHandle calleesNH;
 
     while(csi != cse) {
       const Function *F = *csi;
       DSCallGraph::scc_iterator sccii = callgraph.scc_begin(F),
                                 sccee = callgraph.scc_end(F);
       for(;sccii != sccee; ++sccii) {
-        DSGraph::ScalarMapTy::const_iterator I = SM.find(*sccii);
+        DSGraph::ScalarMapTy::const_iterator I = SM.find(SM.getLeaderForGlobal(*sccii));
         if (I != SM.end()) {
           calleesNH.mergeWith(I->second);
         }

Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=120781&r1=120780&r2=120781&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Thu Dec  2 19:58:27 2010
@@ -892,7 +892,9 @@
     CalleeGraph = Graphs.getDSGraph(*CF);
   } else {
     DEBUG(errs() << "  Handling indirect call: " << *TheCall << "\n");
-    
+    DSGraph *G =  Graphs.getGlobalsGraph();
+    DSGraph::ScalarMapTy& SM = G->getScalarMap();
+
     // Here we fill in CF with one of the possible called functions.  Because we
     // merged together all of the arguments to all of the functions in the
     // equivalence set, it doesn't really matter which one we pick.
@@ -914,23 +916,53 @@
     //
     const DSCallGraph & callGraph = Graphs.getCallGraph();
     unsigned maxArgsWithNodes = 0;
+
     DSCallGraph::callee_iterator I = callGraph.callee_begin(OrigInst);
     for (; I != callGraph.callee_end(OrigInst); ++I) {
+      for(DSCallGraph::scc_iterator sccii = callGraph.scc_begin(*I),
+                           sccee = callGraph.scc_end(*I); sccii != sccee; ++sccii){
+        if(SM.find(SM.getLeaderForGlobal(*sccii)) == SM.end())
+          continue;
+        //
+        // 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(**sccii))) return;
+        // For all other cases Func Info must exist.
+        FuncInfo *CFI = PAInfo.getFuncInfo(**sccii);
+        //
+        // If this target takes more DSNodes than the last one we found, then
+        // make *this* target our canonical target.
+        //
+        if (CFI->ArgNodes.size() >= maxArgsWithNodes) {
+          maxArgsWithNodes = CFI->ArgNodes.size();
+          CF = *sccii;
+        }
+      }
+    }
+    const Function *F1 = OrigInst->getParent()->getParent();
+    F1 = callGraph.sccLeader(&*F1);
+
+    for(DSCallGraph::scc_iterator sccii = callGraph.scc_begin(F1),
+                           sccee = callGraph.scc_end(F1); sccii != sccee; ++sccii){
+        if(SM.find(SM.getLeaderForGlobal(*sccii)) == SM.end())
+          continue;
       //
       // 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;
+      if (!(Graphs.hasDSGraph(**sccii))) return;
       // For all other cases Func Info must exist.
-      FuncInfo *CFI = PAInfo.getFuncInfo(**I);
+      FuncInfo *CFI = PAInfo.getFuncInfo(**sccii);
       //
       // If this target takes more DSNodes than the last one we found, then
       // make *this* target our canonical target.
       //
       if (CFI->ArgNodes.size() >= maxArgsWithNodes) {
         maxArgsWithNodes = CFI->ArgNodes.size();
-        CF = *I;
+        CF = *sccii;
       }
     }
     
@@ -942,33 +974,6 @@
     // This isn't ideal as it means that this call site didn't have inlining
     // happen.
     //
-    /*if (!CF) {
-      DSGraph* dg = Graphs.getDSGraph(*OrigInst->getParent()->getParent());
-      DSNode* d = dg->getNodeForValue(OrigInst->getOperand(0)).getNode();
-      assert (d && "No DSNode!\n");
-      std::vector<const Function*> g;
-      d->addFullFunctionList(g);
-      
-      //if(!(d->isIncompleteNode()) && !(d->isExternalNode()) && !(d->isCollapsedNode())) {
-      
-      //
-      // Perform some consistency checks on the callees.
-      //
-      verifyCallees (g);
-
-      //
-      // If we found any callees, grab the first one with a DSGraph and use it.
-      // Since we're using EQBU/EQTD, all potential targets should have the
-      // 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;
-        }
-      }
-    }*/
 
     //
     // If we still haven't been able to find a target function of the call site





More information about the llvm-commits mailing list