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

Andrew Lenharth alenhar2 at cs.uiuc.edu
Wed Oct 15 09:25:24 PDT 2008


Author: alenhar2
Date: Wed Oct 15 11:25:24 2008
New Revision: 57584

URL: http://llvm.org/viewvc/llvm-project?rev=57584&view=rev
Log:
Fix infinate loop when no ds graph is computed for a call site, but some targets are known

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

Modified: poolalloc/trunk/include/dsa/DataStructure.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=57584&r1=57583&r2=57584&view=diff

==============================================================================
--- poolalloc/trunk/include/dsa/DataStructure.h (original)
+++ poolalloc/trunk/include/dsa/DataStructure.h Wed Oct 15 11:25:24 2008
@@ -219,16 +219,18 @@
 
   const char* debugname;
   bool useCallGraph;
+  bool ReInlineGlobals;
 
 public:
   static char ID;
-  //Child constructor
+  //Child constructor (CBU)
   BUDataStructures(intptr_t CID, const char* name, const char* printname)
-    : DataStructures(CID, printname), debugname(name), useCallGraph(true) {}
+    : DataStructures(CID, printname), debugname(name), useCallGraph(true),
+      ReInlineGlobals(true) {}
   //main constructor
   BUDataStructures() 
     : DataStructures((intptr_t)&ID, "bu."), debugname("dsa-bu"),
-      useCallGraph(false) {}
+      useCallGraph(false), ReInlineGlobals(false) {}
   ~BUDataStructures() { releaseMemory(); }
 
   virtual bool runOnModule(Module &M);

Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=57584&r1=57583&r2=57584&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Wed Oct 15 11:25:24 2008
@@ -387,17 +387,24 @@
   // 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.
-  if (ContainsMain) {
+  if (ContainsMain || ReInlineGlobals) {
     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 = GG.getScalarMap().global_begin(),
-           E = GG.getScalarMap().global_end(); I != E; ++I)
-      if (isa<GlobalVariable>(*I))
-        RC.getClonedNH(GG.getNodeForValue(*I));
+    if (ContainsMain) {
+      // Clone the global nodes into this graph.
+      for (DSScalarMap::global_iterator I = GG.getScalarMap().global_begin(),
+             E = GG.getScalarMap().global_end(); I != E; ++I)
+        if (isa<GlobalVariable>(*I))
+          RC.getClonedNH(GG.getNodeForValue(*I));
+    } else {
+      // Clone used the global nodes into this graph.
+      for (DSScalarMap::global_iterator I = Graph.getScalarMap().global_begin(),
+             E = Graph.getScalarMap().global_end(); I != E; ++I)
+        if (isa<GlobalVariable>(*I))
+          RC.getClonedNH(GG.getNodeForValue(*I));
+    }
   }
 
 
@@ -471,68 +478,67 @@
             CalledFuncs.erase(CalledFuncs.begin() + x);
           else
             ++x;
-        if (!CalledFuncs.size())
-          continue;
       }
-
-      // See if we already computed a graph for this set of callees.
-      std::sort(CalledFuncs.begin(), CalledFuncs.end());
-      std::pair<DSGraph*, std::vector<DSNodeHandle> > &IndCallGraph =
-        IndCallGraphMap[CalledFuncs];
-      
-      if (IndCallGraph.first == 0) {
-        std::vector<const Function*>::iterator I = CalledFuncs.begin(),
-          E = CalledFuncs.end();
-        
-        // Start with a copy of the first graph.
-        GI = IndCallGraph.first = new DSGraph(getDSGraph(**I), GlobalECs);
-        GI->setGlobalsGraph(Graph.getGlobalsGraph());
-        std::vector<DSNodeHandle> &Args = IndCallGraph.second;
-        
-        // Get the argument nodes for the first callee.  The return value is
-        // the 0th index in the vector.
-        GI->getFunctionArgumentsForCall(*I, Args);
+      if (CalledFuncs.size()) {
+        // See if we already computed a graph for this set of callees.
+        std::sort(CalledFuncs.begin(), CalledFuncs.end());
+        std::pair<DSGraph*, std::vector<DSNodeHandle> > &IndCallGraph =
+          IndCallGraphMap[CalledFuncs];
         
-        // Merge all of the other callees into this graph.
-        for (++I; I != E; ++I) {
-          // If the graph already contains the nodes for the function, don't
-          // bother merging it in again.
-          if (!GI->containsFunction(*I)) {
-            GI->cloneInto(getDSGraph(**I));
-            ++NumInlines;
-          }
+        if (IndCallGraph.first == 0) {
+          std::vector<const Function*>::iterator I = CalledFuncs.begin(),
+            E = CalledFuncs.end();
           
-          std::vector<DSNodeHandle> NextArgs;
-          GI->getFunctionArgumentsForCall(*I, NextArgs);
-          unsigned i = 0, e = Args.size();
-          for (; i != e; ++i) {
-            if (i == NextArgs.size()) break;
-            Args[i].mergeWith(NextArgs[i]);
+          // Start with a copy of the first graph.
+          GI = IndCallGraph.first = new DSGraph(getDSGraph(**I), GlobalECs);
+          GI->setGlobalsGraph(Graph.getGlobalsGraph());
+          std::vector<DSNodeHandle> &Args = IndCallGraph.second;
+          
+          // Get the argument nodes for the first callee.  The return value is
+          // the 0th index in the vector.
+          GI->getFunctionArgumentsForCall(*I, Args);
+          
+          // Merge all of the other callees into this graph.
+          for (++I; I != E; ++I) {
+            // If the graph already contains the nodes for the function, don't
+            // bother merging it in again.
+            if (!GI->containsFunction(*I)) {
+              GI->cloneInto(getDSGraph(**I));
+              ++NumInlines;
+            }
+            
+            std::vector<DSNodeHandle> NextArgs;
+            GI->getFunctionArgumentsForCall(*I, NextArgs);
+            unsigned i = 0, e = Args.size();
+            for (; i != e; ++i) {
+              if (i == NextArgs.size()) break;
+              Args[i].mergeWith(NextArgs[i]);
+            }
+            for (e = NextArgs.size(); i != e; ++i)
+              Args.push_back(NextArgs[i]);
           }
-          for (e = NextArgs.size(); i != e; ++i)
-            Args.push_back(NextArgs[i]);
+          
+          // Clean up the final graph!
+          GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
+        } else {
+          DOUT << "***\n*** RECYCLED GRAPH ***\n***\n";
         }
         
-        // Clean up the final graph!
-        GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
-      } else {
-        DOUT << "***\n*** RECYCLED GRAPH ***\n***\n";
+        GI = IndCallGraph.first;
+        
+        // Merge the unified graph into this graph now.
+        DOUT << "    Inlining multi callee graph "
+             << "[" << GI->getGraphSize() << "+"
+             << GI->getAuxFunctionCalls().size() << "] into '"
+             << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+"
+             << Graph.getAuxFunctionCalls().size() << "]\n";
+        
+        Graph.mergeInGraph(CS, IndCallGraph.second, *GI,
+                           DSGraph::StripAllocaBit |
+                           DSGraph::DontCloneCallNodes|
+                           (isComplete?0:DSGraph::DontCloneAuxCallNodes));
+        ++NumInlines;
       }
-      
-      GI = IndCallGraph.first;
-      
-      // Merge the unified graph into this graph now.
-      DOUT << "    Inlining multi callee graph "
-           << "[" << GI->getGraphSize() << "+"
-           << GI->getAuxFunctionCalls().size() << "] into '"
-           << Graph.getFunctionNames() << "' [" << Graph.getGraphSize() <<"+"
-           << Graph.getAuxFunctionCalls().size() << "]\n";
-      
-      Graph.mergeInGraph(CS, IndCallGraph.second, *GI,
-                         DSGraph::StripAllocaBit |
-                         DSGraph::DontCloneCallNodes|
-                         (isComplete?0:DSGraph::DontCloneAuxCallNodes));
-      ++NumInlines;
     }
     if (!isComplete)
       AuxCallsList.push_front(CS);





More information about the llvm-commits mailing list