[llvm-commits] [poolalloc] r121701 - in /poolalloc/trunk/lib/PoolAllocate: PoolAllocate.cpp TransformFunctionBody.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Mon Dec 13 07:55:23 PST 2010


Author: aggarwa4
Date: Mon Dec 13 09:55:23 2010
New Revision: 121701

URL: http://llvm.org/viewvc/llvm-project?rev=121701&view=rev
Log:
While building FuncInfo for the functions, we should
look at the call graph to determine, which functions
should be in the same EQ, and hence should get the 
same number of args.
Since, we have already ensured that all targets, 
for the same call site have the same number of 
pool args, we can just choose any one to instrument
the call site.

Modified:
    poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
    poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=121701&r1=121700&r2=121701&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Mon Dec 13 09:55:23 2010
@@ -658,6 +658,45 @@
   // for corresponding arguments.  Therefore, we want to process all the
   // functions in the same equivalence class once to avoid doing extra work.
   //
+  const DSCallGraph & callgraph = Graphs->getCallGraph();
+  DSGraph* G = Graphs->getGlobalsGraph();
+  DSGraph::ScalarMapTy& SM = G->getScalarMap();
+  for (DSCallGraph::callee_key_iterator ii = callgraph.key_begin(),
+       ee = callgraph.key_end(); ii != ee; ++ii) {
+    bool isIndirect = ((*ii).getCalledFunction() == NULL);
+
+    if (isIndirect) {
+      std::vector<const Function *> Functions;
+      DSCallGraph::callee_iterator csi = callgraph.callee_begin(*ii),
+                                   cse = callgraph.callee_end(*ii);
+      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(SM.getLeaderForGlobal(*sccii));
+          if (I != SM.end() && !((*sccii)->isDeclaration())) {
+            Functions.push_back (*sccii);
+          }
+        }
+        ++csi;
+      }
+      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() && !((*sccii)->isDeclaration())) {
+          Functions.push_back (*sccii);
+        }
+      }
+    
+      FindFunctionPoolArgs (Functions);
+    }
+  }
+  /*
   EquivalenceClasses<const GlobalValue*> & GlobalECs = Graphs->getGlobalECs();
   EquivalenceClasses<const GlobalValue*>::iterator EQSI = GlobalECs.begin();
   EquivalenceClasses<const GlobalValue*>::iterator EQSE = GlobalECs.end();
@@ -691,7 +730,7 @@
     // class and construct the FuncInfo structure for each one.
     //
     FindFunctionPoolArgs (Functions);
-  }
+  }*/
 
   //
   // Make sure every function has a FuncInfo structure.

Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=121701&r1=121700&r2=121701&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Mon Dec 13 09:55:23 2010
@@ -935,12 +935,12 @@
         // 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;
-        }
+        maxArgsWithNodes = CFI->ArgNodes.size();
+        CF = *sccii;
+        break;
       }
     }
+    if(!CF){
     const Function *F1 = OrigInst->getParent()->getParent();
     F1 = callGraph.sccLeader(&*F1);
 
@@ -960,10 +960,9 @@
       // 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;
-      }
+      maxArgsWithNodes = CFI->ArgNodes.size();
+      CF = *sccii;
+    }
     }
     
     // Assuming the call graph is always correct. And if the call graph reports,





More information about the llvm-commits mailing list