[llvm-commits] [poolalloc] r122376 - /poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Dec 21 15:32:04 PST 2010


Author: aggarwa4
Date: Tue Dec 21 17:32:03 2010
New Revision: 122376

URL: http://llvm.org/viewvc/llvm-project?rev=122376&view=rev
Log:
Do not pass pool args to functions that are in the
same equivalence class as an external function.

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

Modified: poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp?rev=122376&r1=122375&r2=122376&view=diff
==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PoolAllocate.cpp Tue Dec 21 17:32:03 2010
@@ -664,6 +664,7 @@
   for (DSCallGraph::callee_key_iterator ii = callgraph.key_begin(),
        ee = callgraph.key_end(); ii != ee; ++ii) {
     bool isIndirect = ((*ii).getCalledFunction() == NULL);
+    bool externFunctionFound = false;
 
     if (isIndirect) {
       std::vector<const Function *> Functions;
@@ -675,7 +676,11 @@
                                 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())) {
+          if (I != SM.end()) {
+            if ((*sccii)->isDeclaration()) {
+              externFunctionFound = true;
+              break;
+            }
             Functions.push_back (*sccii);
           }
         }
@@ -688,14 +693,36 @@
                                 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())) {
+        if (I != SM.end()) {
+          if ((*sccii)->isDeclaration()) {
+            externFunctionFound = true;
+            break;
+          }
           Functions.push_back (*sccii);
         }
       }
-    
-      FindFunctionPoolArgs (Functions);
+      if(!externFunctionFound) 
+        FindFunctionPoolArgs (Functions);
+      else {
+        // For functions that are in the same equivalence class as an 
+        // external function, we cannot pass pool args. Because we 
+        // cannot know which function the call site calls, the 
+        // internal function or the external ones. 
+        // FIXME: Solve this by devirtualizing the call site.
+        for (unsigned index = 0; index < Functions.size(); ++index) {
+          Function * F = (Function *) Functions[index];
+          if (FunctionInfo.find (F) != FunctionInfo.end()) {
+            FuncInfo & FI =  FunctionInfo.find(F)->second;
+            assert(FI.ArgNodes.size() == 0);
+            continue;
+          }
+          FunctionInfo.insert(std::make_pair(F, FuncInfo(*F))).first->second;
+        }
+      }
+
     }
   }
+  
   /*
   EquivalenceClasses<const GlobalValue*> & GlobalECs = Graphs->getGlobalECs();
   EquivalenceClasses<const GlobalValue*>::iterator EQSI = GlobalECs.begin();





More information about the llvm-commits mailing list