[llvm-commits] [poolalloc] r110225 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/CompleteBottomUp.cpp lib/DSA/DSCallGraph.cpp lib/DSA/EquivClassGraphs.cpp

John Criswell criswell at uiuc.edu
Wed Aug 4 11:06:56 PDT 2010


Author: criswell
Date: Wed Aug  4 13:06:56 2010
New Revision: 110225

URL: http://llvm.org/viewvc/llvm-project?rev=110225&view=rev
Log:
Fixes for PR#7630 with additional repairs to ensure the fix doesn't break
anything.
Modified DSCallGraph::insert() to convert functions into function leaders and
to add new functions as separate SCCs in the call graph.  This should trivially
fix PR#7630 but doesn't, in and of itself, fix 254.gap.
Modified the Complete Bottom Up and EQ Bottom Up passes to clone local
information back into the globals graph.  This fixes some other problems with
254.gap.
Finally, modified the CBU pass so that it converts a function to use its global
leader when doing sanity checks on the call graph.  This fixes a new assertion
that gets triggered when PR#7799 is fixed.

Modified:
    poolalloc/trunk/include/dsa/DataStructure.h
    poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp
    poolalloc/trunk/lib/DSA/DSCallGraph.cpp
    poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp

Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=110225&r1=110224&r2=110225&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Wed Aug  4 13:06:56 2010
@@ -211,6 +211,7 @@
 
   EntryPointAnalysis* EP;
 
+  void cloneIntoGlobals(DSGraph* G);
 public:
   static char ID;
   //Child constructor (CBU)
@@ -235,7 +236,6 @@
 
 private:
   void mergeSCCs();
-  
   DSGraph* postOrder(const Function*,
                      svset<const Function*>& marked);
   
@@ -243,7 +243,6 @@
 
   void CloneAuxIntoGlobal(DSGraph* G);
   void cloneGlobalsInto(DSGraph* G);
-  void cloneIntoGlobals(DSGraph* G);
   void finalizeGlobals(void);
 };
 

Modified: poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp?rev=110225&r1=110224&r2=110225&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp (original)
+++ poolalloc/trunk/lib/DSA/CompleteBottomUp.cpp Wed Aug  4 13:06:56 2010
@@ -37,7 +37,22 @@
   buildIndirectFunctionSets(M);
   formGlobalECs();
 
-  return runOnModuleInternal(M);
+  //
+  // Propagate information from the local graphs to the globals graphs.
+  //
+  for (Module::iterator F = M.begin(); F != M.end(); ++F) {
+    if (!(F->isDeclaration())) {
+      if (DSGraph * Graph = getOrCreateGraph(F)) {
+        cloneIntoGlobals (Graph);
+      }
+    }
+  }
+
+  //
+  // Do bottom-up propagation.
+  //
+  bool modified = runOnModuleInternal(M);
+  return modified;
 }
 
 void CompleteBUDataStructures::buildIndirectFunctionSets(Module &M) {
@@ -48,7 +63,7 @@
   DSGraph* G = getGlobalsGraph();
   DSGraph::ScalarMapTy& SM = G->getScalarMap();
 
-  //mege nodes in the global graph for these functions
+  // Merge nodes in the global graph for these functions
   for (DSCallGraph::callee_key_iterator ii = callgraph.key_begin(),
        ee = callgraph.key_end(); ii != ee; ++ii) {
 
@@ -62,9 +77,15 @@
                                    csee = callgraph.callee_end(*ii);
 
       for (; csii != csee; ++csii) {
-        // Declarations don't have to have entries
-        if(!(*csii)->isDeclaration())
-          assert(SM.count(*csii) && "Indirect function callee not in globals?");
+        //
+        // Declarations don't have to have entries.  Functions may be
+        // equivalence classed already, so we have to check their equivalence
+        // class leader instead of the global itself.
+        //
+        const Function * F = *csii;
+        if (!(F->isDeclaration()))
+          assert (SM.count (SM.getLeaderForGlobal(F)) &&
+                  "Indirect function callee not in globals?");
       }
 
     }
@@ -91,8 +112,9 @@
     // Merge the rest of the callees (that we have entries for) together
     // with the first one.
     for (; csi != cse; ++csi) {
-      if (SM.count(*csi))
+      if (SM.count(*csi)) {
         SrcNH.mergeWith(SM.find(*csi)->second);
+      }
     }
   }
 }

Modified: poolalloc/trunk/lib/DSA/DSCallGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DSCallGraph.cpp?rev=110225&r1=110224&r2=110225&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DSCallGraph.cpp (original)
+++ poolalloc/trunk/lib/DSA/DSCallGraph.cpp Wed Aug  4 13:06:56 2010
@@ -207,12 +207,28 @@
 
 //Filter all call edges.  We only want pointer edges.
 void DSCallGraph::insert(llvm::CallSite CS, const llvm::Function* F) {
-  //Create an empty set for the callee, hence all called functions get to be
-  // in the call graph also.  This simplifies SCC formation
-  SimpleCallees[CS.getInstruction()->getParent()->getParent()];
+  //
+  // Find the function to which the call site belongs.
+  //
+  const llvm::Function * Parent = CS.getInstruction()->getParent()->getParent();
+
+  //
+  // Determine the SCC leaders for both the calling function and the called
+  // function.  If they don't belong to an SCC, add them as leaders.
+  //
+  SCCs.insert (Parent);
+  SCCs.insert (F);
+  const llvm::Function * ParentLeader = SCCs.getLeaderValue (Parent);
+  const llvm::Function * FLeader      = SCCs.getLeaderValue (F);
+
+  //
+  // Create an empty set for the callee; hence, all called functions get to be
+  // in the call graph also.  This simplifies SCC formation.
+  //
+  SimpleCallees[ParentLeader];
   if (F) {
-    ActualCallees[CS].insert(F);
-    SimpleCallees[CS.getInstruction()->getParent()->getParent()].insert(F);
+    ActualCallees[CS].insert(FLeader);
+    SimpleCallees[ParentLeader].insert(FLeader);
   }
 }
 

Modified: poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp?rev=110225&r1=110224&r2=110225&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp (original)
+++ poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp Wed Aug  4 13:06:56 2010
@@ -50,10 +50,17 @@
 }
 
 
-// Merge all graphs that are in the same equivalence class
-// the ensures things like poolalloc only deal with one graph for a 
-// call site
-void EquivBUDataStructures::mergeGraphsByGlobalECs() {
+//
+// Method: mergeGraphsByGlobalECs()
+//
+// Description:
+//  Merge all graphs that are in the same equivalence class.  This ensures
+//  that transforms like Automatic Pool Allocation only see one graph for a 
+//  call site.
+//
+void
+EquivBUDataStructures::mergeGraphsByGlobalECs() {
+  //
   // Merge the graphs for each equivalence class.
   //
   for (EquivalenceClasses<const GlobalValue*>::iterator EQSI = GlobalECs.begin(), 
@@ -86,6 +93,13 @@
         }       
       }
     }
+
+    //
+    // Update the globals graph with any information that has changed due to
+    // graph merging.
+    //
+    if (BaseGraph)
+      cloneIntoGlobals(BaseGraph);
   }
 }
 





More information about the llvm-commits mailing list