[llvm-commits] [poolalloc] r120400 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/BottomUpClosure.cpp lib/DSA/DataStructure.cpp lib/DSA/TopDownClosure.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Mon Nov 29 22:36:48 PST 2010


Author: aggarwa4
Date: Tue Nov 30 00:36:48 2010
New Revision: 120400

URL: http://llvm.org/viewvc/llvm-project?rev=120400&view=rev
Log:
Move cloneIntoGlobals and cloneGlobalsInto to 
DataStructures instead of BUDataStructures, so 
as to reduce code duplication in TD. Also, 
this allows us to use these functions for updating
the graphs in all pases. 

Modified:
    poolalloc/trunk/include/dsa/DataStructure.h
    poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
    poolalloc/trunk/lib/DSA/DataStructure.cpp
    poolalloc/trunk/lib/DSA/TopDownClosure.cpp

Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=120400&r1=120399&r2=120400&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Tue Nov 30 00:36:48 2010
@@ -88,6 +88,9 @@
   void init(TargetData* T);
 
   void formGlobalECs();
+  
+  void cloneIntoGlobals(DSGraph* G);
+  void cloneGlobalsInto(DSGraph* G);
 
   void restoreCorrectCallGraph();
   
@@ -219,9 +222,6 @@
 
   EntryPointAnalysis* EP;
 
-  void cloneIntoGlobals(DSGraph* G);
-  void cloneGlobalsInto(DSGraph* G);
-
   // filterCallees -- Whether or not we filter out illegal callees
   // from the CallGraph.  This is useful while doing original BU,
   // but might be undesirable in other passes such as CBU/EQBU.

Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=120400&r1=120399&r2=120400&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Tue Nov 30 00:36:48 2010
@@ -45,7 +45,7 @@
 //
 bool BUDataStructures::runOnModule(Module &M) {
   init(&getAnalysis<StdLibDataStructures>(), false, true, false, false );
-  EP = &getAnalysis<EntryPointAnalysis>();
+  //EP = &getAnalysis<EntryPointAnalysis>();
 
   return runOnModuleInternal(M);
 }
@@ -82,10 +82,12 @@
   //
   postOrderInline (M);
 
-
+#if 0
+  //DSA does not use entryPoint analysis 
   std::vector<const Function*> EntryPoints;
   EP = &getAnalysis<EntryPointAnalysis>();
   EP->findEntryPoints(M, EntryPoints);
+#endif
 
   // At the end of the bottom-up pass, the globals graph becomes complete.
   // FIXME: This is not the right way to do this, but it is sorta better than
@@ -674,37 +676,3 @@
 
 }
 
-//For Entry Points
-void BUDataStructures::cloneGlobalsInto(DSGraph* Graph) {
-  // If this graph contains main, copy the contents of the globals graph over.
-  // Note that this is *required* for correctness.  If a callee contains a use
-  // of a global, we have to make sure to link up nodes due to global-argument
-  // bindings.
-  const DSGraph* GG = Graph->getGlobalsGraph();
-  ReachabilityCloner RC(Graph, GG,
-                        DSGraph::DontCloneCallNodes |
-                        DSGraph::DontCloneAuxCallNodes);
-
-  // Clone the global nodes into this graph.
-  for (DSScalarMap::global_iterator I = Graph->getScalarMap().global_begin(),
-       E = Graph->getScalarMap().global_end(); I != E; ++I)
-    RC.getClonedNH(GG->getNodeForValue(*I));
-}
-
-//For all graphs
-void BUDataStructures::cloneIntoGlobals(DSGraph* Graph) {
-  // When this graph is finalized, clone the globals in the graph into the
-  // globals graph to make sure it has everything, from all graphs.
-  DSScalarMap &MainSM = Graph->getScalarMap();
-  ReachabilityCloner RC(GlobalsGraph, Graph,
-                        DSGraph::DontCloneCallNodes |
-                        DSGraph::DontCloneAuxCallNodes |
-                        DSGraph::StripAllocaBit);
-
-  // Clone everything reachable from globals in the function graph into the
-  // globals graph.
-  for (DSScalarMap::global_iterator I = MainSM.global_begin(),
-         E = MainSM.global_end(); I != E; ++I)
-    RC.getClonedNH(MainSM[*I]);
-}
-

Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=120400&r1=120399&r2=120400&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Tue Nov 30 00:36:48 2010
@@ -1484,6 +1484,41 @@
   DEBUG(if(MadeChange) G.AssertGraphOK());
 }
 
+//For Entry Points
+void DataStructures::cloneGlobalsInto(DSGraph* Graph) {
+  // If this graph contains main, copy the contents of the globals graph over.
+  // Note that this is *required* for correctness.  If a callee contains a use
+  // of a global, we have to make sure to link up nodes due to global-argument
+  // bindings.
+  const DSGraph* GG = Graph->getGlobalsGraph();
+  ReachabilityCloner RC(Graph, GG,
+                        DSGraph::DontCloneCallNodes |
+                        DSGraph::DontCloneAuxCallNodes);
+
+  // Clone the global nodes into this graph.
+  for (DSScalarMap::global_iterator I = Graph->getScalarMap().global_begin(),
+       E = Graph->getScalarMap().global_end(); I != E; ++I)
+    RC.getClonedNH(GG->getNodeForValue(*I));
+}
+
+//For all graphs
+void DataStructures::cloneIntoGlobals(DSGraph* Graph) {
+  // When this graph is finalized, clone the globals in the graph into the
+  // globals graph to make sure it has everything, from all graphs.
+  DSScalarMap &MainSM = Graph->getScalarMap();
+  ReachabilityCloner RC(GlobalsGraph, Graph,
+                        DSGraph::DontCloneCallNodes |
+                        DSGraph::DontCloneAuxCallNodes |
+                        DSGraph::StripAllocaBit);
+
+  // Clone everything reachable from globals in the function graph into the
+  // globals graph.
+  for (DSScalarMap::global_iterator I = MainSM.global_begin(),
+         E = MainSM.global_end(); I != E; ++I)
+    RC.getClonedNH(MainSM[*I]);
+}
+
+
 void DataStructures::init(DataStructures* D, bool clone, bool useAuxCalls, 
                           bool copyGlobalAuxCalls, bool resetAux) {
   assert (!GraphSource && "Already init");

Modified: poolalloc/trunk/lib/DSA/TopDownClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/TopDownClosure.cpp?rev=120400&r1=120399&r2=120400&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/TopDownClosure.cpp Tue Nov 30 00:36:48 2010
@@ -173,14 +173,7 @@
     if (!(F->isDeclaration())){
       DSGraph *Graph  = getOrCreateGraph(F);
 
-      ReachabilityCloner RC(Graph, GlobalsGraph,
-          DSGraph::DontCloneCallNodes |
-          DSGraph::DontCloneAuxCallNodes);
-      for (DSScalarMap::global_iterator
-          GI = Graph->getScalarMap().global_begin(),
-          E = Graph->getScalarMap().global_end(); GI != E; ++GI)
-        RC.getClonedNH(GlobalsGraph->getNodeForValue(*GI));
-
+      cloneGlobalsInto(Graph);
       // Clean up uninteresting nodes
       Graph->removeDeadNodes(0);
 
@@ -236,16 +229,7 @@
   // then having RemoveDeadNodes clone it back, we should do all of this as a
   // post-pass over all of the graphs.  We need to take cloning out of
   // removeDeadNodes and gut removeDeadNodes at the same time first though. :(
-  {
-    DSGraph* GG = DSG->getGlobalsGraph();
-    ReachabilityCloner RC(DSG, GG,
-                          DSGraph::DontCloneCallNodes |
-                          DSGraph::DontCloneAuxCallNodes);
-    for (DSScalarMap::global_iterator
-           GI = DSG->getScalarMap().global_begin(),
-           E = DSG->getScalarMap().global_end(); GI != E; ++GI)
-      RC.getClonedNH(GG->getNodeForValue(*GI));
-  }
+  cloneGlobalsInto(DSG);
 
   DEBUG(errs() << "[TD] Inlining callers into '" 
 	<< DSG->getFunctionNames() << "'\n");





More information about the llvm-commits mailing list