[llvm-commits] [poolalloc] r78134 - in /poolalloc/trunk: include/rdsa/ lib/rDSA/

Andrew Lenharth alenhar2 at cs.uiuc.edu
Tue Aug 4 17:30:23 PDT 2009


Author: alenhar2
Date: Tue Aug  4 19:30:22 2009
New Revision: 78134

URL: http://llvm.org/viewvc/llvm-project?rev=78134&view=rev
Log:
New branch to clean up DSA some, may focus on precision rather than speed too

Added:
    poolalloc/trunk/include/rdsa/
      - copied from r78082, poolalloc/trunk/include/dsa/
    poolalloc/trunk/include/rdsa/DSNode.h
      - copied, changed from r78087, poolalloc/trunk/include/dsa/DSNode.h
    poolalloc/trunk/lib/rDSA/
      - copied from r78082, poolalloc/trunk/lib/DSA/
    poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/BottomUpClosure.cpp
    poolalloc/trunk/lib/rDSA/CallTargets.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/CallTargets.cpp
    poolalloc/trunk/lib/rDSA/DataStructure.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/DataStructure.cpp
    poolalloc/trunk/lib/rDSA/DataStructureStats.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/DataStructureStats.cpp
    poolalloc/trunk/lib/rDSA/Local.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/Local.cpp
    poolalloc/trunk/lib/rDSA/Printer.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/Printer.cpp
    poolalloc/trunk/lib/rDSA/StdLibPass.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/StdLibPass.cpp
    poolalloc/trunk/lib/rDSA/TopDownClosure.cpp
      - copied, changed from r78088, poolalloc/trunk/lib/DSA/TopDownClosure.cpp
Modified:
    poolalloc/trunk/include/rdsa/DSGraph.h
    poolalloc/trunk/include/rdsa/DSGraphTraits.h
    poolalloc/trunk/include/rdsa/DSSupport.h
    poolalloc/trunk/lib/rDSA/Basic.cpp
    poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp
    poolalloc/trunk/lib/rDSA/DataStructureAA.cpp
    poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp
    poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp
    poolalloc/trunk/lib/rDSA/GraphChecker.cpp
    poolalloc/trunk/lib/rDSA/Makefile
    poolalloc/trunk/lib/rDSA/Steensgaard.cpp
    poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp

Modified: poolalloc/trunk/include/rdsa/DSGraph.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSGraph.h?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/include/rdsa/DSGraph.h (original)
+++ poolalloc/trunk/include/rdsa/DSGraph.h Tue Aug  4 19:30:22 2009
@@ -15,7 +15,7 @@
 #ifndef LLVM_ANALYSIS_DSGRAPH_H
 #define LLVM_ANALYSIS_DSGRAPH_H
 
-#include "dsa/DSNode.h"
+#include "rdsa/DSNode.h"
 #include "llvm/ADT/EquivalenceClasses.h"
 #include "poolalloc/ADT/HashExtras.h"
 

Modified: poolalloc/trunk/include/rdsa/DSGraphTraits.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSGraphTraits.h?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/include/rdsa/DSGraphTraits.h (original)
+++ poolalloc/trunk/include/rdsa/DSGraphTraits.h Tue Aug  4 19:30:22 2009
@@ -16,7 +16,7 @@
 #ifndef LLVM_ANALYSIS_DSGRAPHTRAITS_H
 #define LLVM_ANALYSIS_DSGRAPHTRAITS_H
 
-#include "dsa/DSGraph.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/ADT/iterator.h"
 #include "llvm/ADT/STLExtras.h"

Copied: poolalloc/trunk/include/rdsa/DSNode.h (from r78087, poolalloc/trunk/include/dsa/DSNode.h)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSNode.h?p2=poolalloc/trunk/include/rdsa/DSNode.h&p1=poolalloc/trunk/include/dsa/DSNode.h&r1=78087&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/include/dsa/DSNode.h (original)
+++ poolalloc/trunk/include/rdsa/DSNode.h Tue Aug  4 19:30:22 2009
@@ -14,7 +14,7 @@
 #ifndef LLVM_ANALYSIS_DSNODE_H
 #define LLVM_ANALYSIS_DSNODE_H
 
-#include "dsa/DSSupport.h"
+#include "rdsa/DSSupport.h"
 #include "llvm/Support/Streams.h"
 #include "poolalloc/ADT/HashExtras.h"
 
@@ -289,11 +289,18 @@
   ///
   void mergeWith(const DSNodeHandle &NH, unsigned Offset);
 
-  /// addGlobal - Add an entry for a global value to the Globals list.  This
-  /// also marks the node with the 'G' flag if it does not already have it.
+  /// addGlobal - Add an entry for a global value to the Globals list.
+  /// This also marks the node with the 'G' flag if it does not
+  /// already have it.
   ///
   void addGlobal(const GlobalValue *GV);
 
+  /// addFunction - Add an entry for a function value to the
+  /// Functionss list.  This also marks the node with the 'F' flag if
+  /// it does not already have it.
+  ///
+  void addFunction(const Function* FV);
+
   /// removeGlobal - Remove the specified global that is explicitly in the
   /// globals list.
   void removeGlobal(const GlobalValue *GV);
@@ -483,7 +490,7 @@
   return HandleForwarding();
 }
 
-inline void DSNodeHandle::setTo(DSNode *n, unsigned NewOffset) const {
+inline const DSNodeHandle& DSNodeHandle::setTo(DSNode *n, unsigned NewOffset) const {
   assert((!n || !n->isForwarding()) && "Cannot set node to a forwarded node!");
   if (N) getNode()->NumReferrers--;
   N = n;
@@ -499,6 +506,7 @@
   assert(!N || ((N->NodeType & DSNode::DeadNode) == 0));
   assert((!N || Offset < N->Size || (N->Size == 0 && Offset == 0) ||
           N->isForwarding()) && "Node handle offset out of range!");
+  return *this;
 }
 
 inline bool DSNodeHandle::hasLink(unsigned Num) const {

Modified: poolalloc/trunk/include/rdsa/DSSupport.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSSupport.h?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/include/rdsa/DSSupport.h (original)
+++ poolalloc/trunk/include/rdsa/DSSupport.h Tue Aug  4 19:30:22 2009
@@ -109,7 +109,7 @@
     Offset = O;
   }
 
-  void setTo(DSNode *N, unsigned O) const; // Defined inline in DSNode.h
+  const DSNodeHandle& setTo(DSNode *N, unsigned O) const; // Defined inline in DSNode.h
 
   void addEdgeTo(unsigned LinkNo, const DSNodeHandle &N);
   void addEdgeTo(const DSNodeHandle &N) { addEdgeTo(0, N); }

Modified: poolalloc/trunk/lib/rDSA/Basic.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Basic.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/Basic.cpp (original)
+++ poolalloc/trunk/lib/rDSA/Basic.cpp Tue Aug  4 19:30:22 2009
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 
 #include "llvm/Module.h"
 #include "llvm/DerivedTypes.h"

Copied: poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp (from r78088, poolalloc/trunk/lib/DSA/BottomUpClosure.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp?p2=poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp&p1=poolalloc/trunk/lib/DSA/BottomUpClosure.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp Tue Aug  4 19:30:22 2009
@@ -15,8 +15,8 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "dsa-bu"
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Module.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
@@ -54,14 +54,14 @@
     calculateGraphs(MainFunc, Stack, NextID, ValMap);
     CloneAuxIntoGlobal(getDSGraph(*MainFunc));
   } else {
-    DEBUG(ferrs() << debugname << ": No 'main' function found!\n");
+    DEBUG(errs() << debugname << ": No 'main' function found!\n");
   }
 
   // Calculate the graphs for any functions that are unreachable from main...
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
     if (!I->isDeclaration() && !hasDSGraph(*I)) {
       if (MainFunc)
-        DEBUG(ferrs() << debugname << ": Function unreachable from main: "
+        DEBUG(errs() << debugname << ": Function unreachable from main: "
 	      << I->getName() << "\n");
       calculateGraphs(I, Stack, NextID, ValMap);     // Calculate all graphs.
       CloneAuxIntoGlobal(getDSGraph(*I));
@@ -263,12 +263,12 @@
 
   // If this is a new SCC, process it now.
   if (Stack.back() == F) {           // Special case the single "SCC" case here.
-    DEBUG(ferrs() << "Visiting single node SCC #: " << MyID << " fn: "
+    DEBUG(errs() << "Visiting single node SCC #: " << MyID << " fn: "
 	  << F->getName() << "\n");
     Stack.pop_back();
-    DEBUG(ferrs() << "  [BU] Calculating graph for: " << F->getName()<< "\n");
+    DEBUG(errs() << "  [BU] Calculating graph for: " << F->getName()<< "\n");
     calculateGraph(Graph);
-    DEBUG(ferrs() << "  [BU] Done inlining: " << F->getName() << " ["
+    DEBUG(errs() << "  [BU] Done inlining: " << F->getName() << " ["
 	  << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size()
 	  << "]\n");
 
@@ -297,7 +297,7 @@
     ResolvedFuncs.resize(uid - ResolvedFuncs.begin());
 
     if (ResolvedFuncs.size() || NewCalleeFuncs.size()) {
-      DEBUG(ferrs() << "Recalculating " << F->getName() << " due to new knowledge\n");
+      DEBUG(errs() << "Recalculating " << F->getName() << " due to new knowledge\n");
       ValMap.erase(F);
       return calculateGraphs(F, Stack, NextID, ValMap);
     } else {
@@ -341,7 +341,7 @@
     }
     Stack.pop_back();
 
-    DEBUG(ferrs() << "Calculating graph for SCC #: " << MyID << " of size: "
+    DEBUG(errs() << "Calculating graph for SCC #: " << MyID << " of size: "
 	  << SCCSize << "\n");
 
     // Compute the Max SCC Size.
@@ -354,7 +354,7 @@
     // Now that we have one big happy family, resolve all of the call sites in
     // the graph...
     calculateGraph(SCCGraph);
-    DEBUG(ferrs() << "  [BU] Done inlining SCC  [" << SCCGraph->getGraphSize()
+    DEBUG(errs() << "  [BU] Done inlining SCC  [" << SCCGraph->getGraphSize()
 	  << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n"
 	  << "DONE with SCC #: " << MyID << "\n");
 
@@ -473,7 +473,7 @@
       // Get the data structure graph for the called function.
       GI = getDSGraph(*Callee);  // Graph to inline
       DEBUG(GI->AssertGraphOK(); GI->getGlobalsGraph()->AssertGraphOK());
-      DEBUG(ferrs() << "    Inlining graph for " << Callee->getName()
+      DEBUG(errs() << "    Inlining graph for " << Callee->getName()
 	    << "[" << GI->getGraphSize() << "+"
 	    << GI->getAuxFunctionCalls().size() << "] into '"
 	    << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
@@ -484,19 +484,19 @@
       ++NumInlines;
       DEBUG(Graph->AssertGraphOK(););
     } else if (CalledFuncs.size() > 1) {
-      DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n");
-      DEBUG(ferrs() << "  calls " << CalledFuncs.size()
+      DEBUG(errs() << "In Fns: " << Graph->getFunctionNames() << "\n");
+      DEBUG(errs() << "  calls " << CalledFuncs.size()
             << " fns from site: " << CS.getCallSite().getInstruction()
             << "  " << *CS.getCallSite().getInstruction());
-      DEBUG(ferrs() << "   Fns =");
+      DEBUG(errs() << "   Fns =");
       unsigned NumPrinted = 0;
       
       for (std::vector<const Function*>::iterator I = CalledFuncs.begin(),
              E = CalledFuncs.end(); I != E; ++I)
         if (NumPrinted++ < 8) {
-	  DEBUG(ferrs() << " " << (*I)->getName());
+	  DEBUG(errs() << " " << (*I)->getName());
 	}
-      DEBUG(ferrs() << "\n");
+      DEBUG(errs() << "\n");
       
       if (!isComplete) {
         for (unsigned x = 0; x < CalledFuncs.size(); )
@@ -547,13 +547,13 @@
           // Clean up the final graph!
           GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
         } else {
-          DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n");
+          DEBUG(errs() << "***\n*** RECYCLED GRAPH ***\n***\n");
         }
         
         GI = IndCallGraph.first;
         
         // Merge the unified graph into this graph now.
-        DEBUG(ferrs() << "    Inlining multi callee graph "
+        DEBUG(errs() << "    Inlining multi callee graph "
 	      << "[" << GI->getGraphSize() << "+"
 	      << GI->getAuxFunctionCalls().size() << "] into '"
 	      << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
@@ -622,7 +622,7 @@
       // Get the data structure graph for the called function.
       GI = getDSGraph(*Callee);  // Graph to inline
       if (GI == Graph) continue;
-      DEBUG(ferrs() << "    Inlining graph for " << Callee->getName()
+      DEBUG(errs() << "    Inlining graph for " << Callee->getName()
 	    << "[" << GI->getGraphSize() << "+"
 	    << GI->getAuxFunctionCalls().size() << "] into '"
 	    << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"
@@ -631,19 +631,19 @@
                          DSGraph::StripAllocaBit|DSGraph::DontCloneCallNodes);
       ++NumInlines;
     } else {
-      DEBUG(ferrs() << "In Fns: " << Graph->getFunctionNames() << "\n");
+      DEBUG(errs() << "In Fns: " << Graph->getFunctionNames() << "\n");
       DEBUG(std::cerr << "  calls " << CalledFuncs.size()
             << " fns from site: " << CS.getCallSite().getInstruction()
             << "  " << *CS.getCallSite().getInstruction());
-      DEBUG(ferrs() << "   Fns =");
+      DEBUG(errs() << "   Fns =");
       unsigned NumPrinted = 0;
       
       for (std::vector<const Function*>::iterator I = CalledFuncs.begin(),
              E = CalledFuncs.end(); I != E; ++I)
         if (NumPrinted++ < 8) {
-	  DEBUG(ferrs() << " " << (*I)->getName());
+	  DEBUG(errs() << " " << (*I)->getName());
 	}
-      DEBUG(ferrs() << "\n");
+      DEBUG(errs() << "\n");
       
       for (unsigned x = 0; x < CalledFuncs.size(); )
         if (!hasDSGraph(*CalledFuncs[x]))
@@ -696,13 +696,13 @@
         // Clean up the final graph!
         GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
       } else {
-        DEBUG(ferrs() << "***\n*** RECYCLED GRAPH ***\n***\n");
+        DEBUG(errs() << "***\n*** RECYCLED GRAPH ***\n***\n");
       }
       
       GI = IndCallGraph.first;
       
       // Merge the unified graph into this graph now.
-      DEBUG(ferrs() << "    Inlining multi callee graph "
+      DEBUG(errs() << "    Inlining multi callee graph "
             << "[" << GI->getGraphSize() << "+"
             << GI->getAuxFunctionCalls().size() << "] into '"
             << Graph->getFunctionNames() << "' [" << Graph->getGraphSize() <<"+"

Copied: poolalloc/trunk/lib/rDSA/CallTargets.cpp (from r78088, poolalloc/trunk/lib/DSA/CallTargets.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/CallTargets.cpp?p2=poolalloc/trunk/lib/rDSA/CallTargets.cpp&p1=poolalloc/trunk/lib/DSA/CallTargets.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/CallTargets.cpp (original)
+++ poolalloc/trunk/lib/rDSA/CallTargets.cpp Tue Aug  4 19:30:22 2009
@@ -19,9 +19,9 @@
 
 #include "llvm/Module.h"
 #include "llvm/Instructions.h"
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
-#include "dsa/CallTargets.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
+#include "rdsa/CallTargets.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FormattedStream.h"
@@ -74,7 +74,7 @@
                 } 
                 if (N->isCompleteNode() && !IndMap[cs].size()) {
                   ++CompleteEmpty;
-                  DEBUG(ferrs() << "Call site empty: '"
+                  DEBUG(errs() << "Call site empty: '"
 			<< cs.getInstruction()->getName() 
 			<< "' In '"
 			<< cs.getInstruction()->getParent()->getParent()->getName()

Modified: poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp (original)
+++ poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp Tue Aug  4 19:30:22 2009
@@ -14,8 +14,8 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "dsa-cbu"
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Module.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/Debug.h"

Copied: poolalloc/trunk/lib/rDSA/DataStructure.cpp (from r78088, poolalloc/trunk/lib/DSA/DataStructure.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructure.cpp?p2=poolalloc/trunk/lib/rDSA/DataStructure.cpp&p1=poolalloc/trunk/lib/DSA/DataStructure.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructure.cpp Tue Aug  4 19:30:22 2009
@@ -11,10 +11,10 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DSGraphTraits.h"
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
-#include "dsa/DSSupport.h"
+#include "rdsa/DSGraphTraits.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
+#include "rdsa/DSSupport.h"
 #include "llvm/Constants.h"
 #include "llvm/Function.h"
 #include "llvm/GlobalVariable.h"
@@ -234,6 +234,14 @@
   }
 }
 
+/// addFunction - Add an entry for a function value to the
+/// Functionss list.  This also marks the node with the 'F' flag if
+/// it does not already have it.
+///
+void DSNode::addFunction(const Function* FV) {
+  addGlobal(FV);
+}
+
 // removeGlobal - Remove the specified global that is explicitly in the globals
 // list.
 void DSNode::removeGlobal(const GlobalValue *GV) {

Modified: poolalloc/trunk/lib/rDSA/DataStructureAA.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructureAA.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/DataStructureAA.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructureAA.cpp Tue Aug  4 19:30:22 2009
@@ -18,8 +18,8 @@
 #include "llvm/Module.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/Passes.h"
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 using namespace llvm;
 
 namespace {

Modified: poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp Tue Aug  4 19:30:22 2009
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Module.h"
 #include "llvm/Constant.h"

Copied: poolalloc/trunk/lib/rDSA/DataStructureStats.cpp (from r78088, poolalloc/trunk/lib/DSA/DataStructureStats.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/DataStructureStats.cpp?p2=poolalloc/trunk/lib/rDSA/DataStructureStats.cpp&p1=poolalloc/trunk/lib/DSA/DataStructureStats.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructureStats.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructureStats.cpp Tue Aug  4 19:30:22 2009
@@ -11,8 +11,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Function.h"
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"
@@ -97,7 +97,7 @@
         totalNumCallees  += Callees.size();
         ++numIndirectCalls;
       } else {
-        DEBUG(ferrs() << "WARNING: No callee in Function '" 
+        DEBUG(errs() << "WARNING: No callee in Function '" 
 	      << F.getNameStr() << "' at call: \n"
 	      << *I->getCallSite().getInstruction());
       }
@@ -107,7 +107,7 @@
   NumIndirectCalls += numIndirectCalls;
 
   if (numIndirectCalls) {
-    DEBUG(ferrs() << "  In function " << F.getName() << ":  "
+    DEBUG(errs() << "  In function " << F.getName() << ":  "
 	  << (totalNumCallees / (double) numIndirectCalls)
 	  << " average callees per indirect call\n");
   }

Modified: poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp (original)
+++ poolalloc/trunk/lib/rDSA/EquivClassGraphs.cpp Tue Aug  4 19:30:22 2009
@@ -15,11 +15,11 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "ECGraphs"
-#include "dsa/DataStructure.h"
+#include "rdsa/DataStructure.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Module.h"
 #include "llvm/Pass.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/ADT/SCCIterator.h"

Modified: poolalloc/trunk/lib/rDSA/GraphChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/GraphChecker.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/GraphChecker.cpp (original)
+++ poolalloc/trunk/lib/rDSA/GraphChecker.cpp Tue Aug  4 19:30:22 2009
@@ -23,8 +23,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Streams.h"
 #include "llvm/Value.h"

Copied: poolalloc/trunk/lib/rDSA/Local.cpp (from r78088, poolalloc/trunk/lib/DSA/Local.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Local.cpp?p2=poolalloc/trunk/lib/rDSA/Local.cpp&p1=poolalloc/trunk/lib/DSA/Local.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/rDSA/Local.cpp Tue Aug  4 19:30:22 2009
@@ -12,8 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
@@ -41,42 +41,100 @@
 X("dsa-local", "Local Data Structure Analysis");
 
 namespace {
+
   //===--------------------------------------------------------------------===//
-  //  GraphBuilder Class
+  //  GraphBuilderBase Class
   //===--------------------------------------------------------------------===//
   //
-  /// This class is the builder class that constructs the local data structure
-  /// graph by performing a single pass over the function in question.
+  /// This class contains the common graph building coe.
   ///
-  class GraphBuilder : InstVisitor<GraphBuilder> {
-    DSGraph &G;
-    Function* FB;
-    DataStructures* DS;
-
-    ////////////////////////////////////////////////////////////////////////////
-    // Helper functions used to implement the visitation functions...
-
-    void MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C);
-
+  class GraphBuilderBase {
+    DSGraph* G;
+  protected:
     /// createNode - Create a new DSNode, ensuring that it is properly added to
     /// the graph.
     ///
-    DSNode *createNode(const Type *Ty = 0) 
-    {   
-      DSNode* ret = new DSNode(Ty, &G);
-      assert(ret->getParentGraph() && "No parent?");
-      return ret;
+    DSNode* createNode(const Type *Ty = 0) {   
+      return new DSNode(Ty, G);
+    }
+    DSNode* createNode(const Type *Ty, GlobalVariable* GV) {   
+      DSNode* N = new DSNode(Ty, G);
+      N->addGlobal(GV);
+      return N;
+    }
+    DSNode* createNode(const Type *Ty, Function* FV) {   
+      DSNode* N = new DSNode(Ty, G);
+      N->addFunction(FV);
+      return N;
+    }
+
+    DSNodeHandle& getNodeForValue(const Value *V) { 
+      return G->getScalarMap()[V];
+    }
+
+    bool hasNodeForValue(const Value* V) const {
+      return G->hasNodeForValue(V);
+    }
+    void eraseNodeForValue(const Value* V) {
+      G->eraseNodeForValue(V);
+    }
+
+    void addDSCallSite(const DSCallSite& DSCS) {
+      G->getFunctionCalls().push_back(DSCS);
     }
 
+    /// getValueDest - Return the DSNode that the actual value points to.
+    ///
+    DSNodeHandle getValueDest(Value &V);
+
     /// setDestTo - Set the ScalarMap entry for the specified value to point to
     /// the specified destination.  If the Value already points to a node, make
     /// sure to merge the two destinations together.
     ///
     void setDestTo(Value &V, const DSNodeHandle &NH);
 
-    /// getValueDest - Return the DSNode that the actual value points to.
-    ///
-    DSNodeHandle getValueDest(Value &V);
+    void visitGetElementPtrInst(User &GEP);
+
+    GraphBuilderBase(DSGraph* _G) :G(_G) {}
+
+  };
+
+  //===--------------------------------------------------------------------===//
+  //  GraphBuilderGlobal Class
+  //===--------------------------------------------------------------------===//
+  //
+  /// This class is the builder class that constructs the local data structure
+  /// graph by performing a single pass over the function in question.
+  ///
+  class GraphBuilderGlobal : GraphBuilderBase {
+
+    void MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C);
+
+  public:
+    // GraphBuilderGlobal ctor for working on the globals graph
+    explicit GraphBuilderGlobal(DSGraph* g)
+      :GraphBuilderBase(g)
+    {}
+
+    void mergeInGlobalInitializer(GlobalVariable *GV);
+    void mergeFunction(Function& F) { getValueDest(F); }
+
+  };
+
+ 
+  //===--------------------------------------------------------------------===//
+  //  GraphBuilderLocal Class
+  //===--------------------------------------------------------------------===//
+  //
+  /// This class is the builder class that constructs the local data structure
+  /// graph by performing a single pass over the function in question.
+  ///
+  class GraphBuilderLocal : GraphBuilderBase, InstVisitor<GraphBuilderLocal> {
+    DataStructures* DS;
+    DSNodeHandle&  RetNode;
+
+    ////////////////////////////////////////////////////////////////////////////
+    // Helper functions used to implement the visitation functions...
 
     /// getLink - This method is used to return the specified link in the
     /// specified node if one exists.  If a link does not already exist (it's
@@ -86,7 +144,7 @@
 
     ////////////////////////////////////////////////////////////////////////////
     // Visitor functions, used to handle each instruction type we encounter...
-    friend class InstVisitor<GraphBuilder>;
+    friend class InstVisitor<GraphBuilderLocal>;
 
     void visitMallocInst(MallocInst &MI)
     { setDestTo(MI, createNode()->setHeapMarker()); }
@@ -111,18 +169,23 @@
     void visitBitCastInst(BitCastInst &I);
     void visitCmpInst(CmpInst &I);
 
+    void visitExtractValueInst(ExtractValueInst &I);
+    void visitInsertValueInst(InsertValueInst &I);
+
     //the nasty ones
-    void visitGetElementPtrInst(User &GEP);
     void visitCallInst(CallInst &CI);
     void visitInvokeInst(InvokeInst &II);
     void visitInstruction(Instruction &I);
+    void visitGetElementPtrInst(User &GEP) { 
+      GraphBuilderBase::visitGetElementPtrInst(GEP);
+    }
 
     bool visitIntrinsic(CallSite CS, Function* F);
     void visitCallSite(CallSite CS);
 
   public:
-    GraphBuilder(Function &f, DSGraph &g, DataStructures& DSi)
-      : G(g), FB(&f), DS(&DSi) {
+    GraphBuilderLocal(Function& f, DSNodeHandle& retnode, DSGraph* g, DataStructures& DSi)
+      : GraphBuilderBase(g), DS(&DSi), RetNode(retnode) {
       // Create scalar nodes for all pointer arguments...
       for (Function::arg_iterator I = f.arg_begin(), E = f.arg_end();
            I != E; ++I) {
@@ -135,37 +198,26 @@
         }
       }
 
-      // Create an entry for the return, which tracks which functions are in
-      // the graph
-      g.getOrCreateReturnNodeFor(f);
-
       visit(f);  // Single pass over the function
 
       // If there are any constant globals referenced in this function, merge
       // their initializers into the local graph from the globals graph.
-      if (g.getScalarMap().global_begin() != g.getScalarMap().global_end()) {
-        ReachabilityCloner RC(&g, g.getGlobalsGraph(), 0);
+      if (g->getScalarMap().global_begin() != g->getScalarMap().global_end()) {
+        ReachabilityCloner RC(g, g->getGlobalsGraph(), 0);
         
-        for (DSScalarMap::global_iterator I = g.getScalarMap().global_begin();
-             I != g.getScalarMap().global_end(); ++I)
+        for (DSScalarMap::global_iterator I = g->getScalarMap().global_begin();
+             I != g->getScalarMap().global_end(); ++I)
           if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(*I))
             if (!GV->isDeclaration() && GV->isConstant())
-              RC.merge(g.getNodeForValue(GV), g.getGlobalsGraph()->getNodeForValue(GV));
+              RC.merge(g->getNodeForValue(GV), g->getGlobalsGraph()->getNodeForValue(GV));
       }
       
-      g.markIncompleteNodes(DSGraph::MarkFormalArgs);
+      g->markIncompleteNodes(DSGraph::MarkFormalArgs);
       
       // Remove any nodes made dead due to merging...
-      g.removeDeadNodes(DSGraph::KeepUnreachableGlobals);
+      g->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
     }
 
-    // GraphBuilder ctor for working on the globals graph
-    explicit GraphBuilder(DSGraph& g)
-      :G(g), FB(0)
-    {}
-
-    void mergeInGlobalInitializer(GlobalVariable *GV);
-    void mergeFunction(Function& F) { getValueDest(F); }
   };
 
   /// Traverse the whole DSGraph, and propagate the unknown flags through all 
@@ -198,28 +250,37 @@
 ///
 /// getValueDest - Return the DSNode that the actual value points to.
 ///
-DSNodeHandle GraphBuilder::getValueDest(Value &Val) {
+DSNodeHandle GraphBuilderBase::getValueDest(Value &Val) {
   Value *V = &Val;
   if (isa<Constant>(V) && cast<Constant>(V)->isNullValue()) 
     return 0;  // Null doesn't point to anything, don't add to ScalarMap!
 
-  DSNodeHandle &NH = G.getNodeForValue(V);
+  DSNodeHandle &NH = getNodeForValue(V);
   if (!NH.isNull())
     return NH;     // Already have a node?  Just return it...
 
   // Otherwise we need to create a new node to point to.
+
+  if (GlobalVariable* GV = dyn_cast<GlobalVariable>(V))
+    // Create a new global node for this global variable.
+    return NH.setTo(createNode(GV->getType()->getElementType(), GV), 0);
+
+  if (Function* FV = dyn_cast<Function>(V))
+    // Create a new global node for this global variable.
+    return NH.setTo(createNode(0, FV), 0);
+
+  if (GlobalAlias* GA = dyn_cast<GlobalAlias>(V))
+    return NH = getValueDest(*(GA->getAliasee()));
+
+  if (isa<UndefValue>(V)) {
+    eraseNodeForValue(V);
+    return 0;
+  }
+
   // Check first for constant expressions that must be traversed to
   // extract the actual value.
   DSNode* N;
-  if (GlobalVariable* GV = dyn_cast<GlobalVariable>(V)) {
-    // Create a new global node for this global variable.
-    N = createNode(GV->getType()->getElementType());
-    N->addGlobal(GV);
-  } else if (Function* GV = dyn_cast<Function>(V)) {
-    // Create a new global node for this global variable.
-    N = createNode();
-    N->addGlobal(GV);
-  } else if (Constant *C = dyn_cast<Constant>(V)) {
+  if (Constant *C = dyn_cast<Constant>(V)) {
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
       if (CE->isCast()) {
         if (isa<PointerType>(CE->getOperand(0)->getType()))
@@ -228,29 +289,19 @@
           NH = createNode()->setUnknownMarker();
       } else if (CE->getOpcode() == Instruction::GetElementPtr) {
         visitGetElementPtrInst(*CE);
-        assert(G.hasNodeForValue(CE) && "GEP didn't get processed right?");
-        NH = G.getNodeForValue(CE);
+        assert(hasNodeForValue(CE) && "GEP didn't get processed right?");
+        NH = getNodeForValue(CE);
       } else {
         // This returns a conservative unknown node for any unhandled ConstExpr
         return NH = createNode()->setUnknownMarker();
       }
       if (NH.isNull()) {  // (getelementptr null, X) returns null
-        G.eraseNodeForValue(V);
+        eraseNodeForValue(V);
         return 0;
       }
       return NH;
-    } else if (isa<UndefValue>(C)) {
-      G.eraseNodeForValue(V);
-      return 0;
-    } else if (isa<GlobalAlias>(C)) {
-      // XXX: Need more investigation
-      // According to Andrew, DSA is broken on global aliasing, since it does
-      // not handle the aliases of parameters correctly. Here is only a quick
-      // fix for some special cases.
-      NH = getValueDest(*(cast<GlobalAlias>(C)->getAliasee()));
-      return 0;
     } else {
-      DEBUG(ferrs() << "Unknown constant: " << *C << "\n");
+      DEBUG(errs() << "Unknown constant: " << *C << "\n");
       assert(0 && "Unknown constant type!");
     }
     N = createNode(); // just create a shadow node
@@ -259,8 +310,7 @@
     N = createNode();
   }
 
-  NH.setTo(N, 0);      // Remember that we are pointing to it...
-  return NH;
+  return NH.setTo(N, 0);      // Remember that we are pointing to it...
 }
 
 
@@ -270,7 +320,7 @@
 /// specify the type of the Node field we are accessing so that we know what
 /// type should be linked to if we need to create a new node.
 ///
-DSNodeHandle &GraphBuilder::getLink(const DSNodeHandle &node, unsigned LinkNo) {
+DSNodeHandle &GraphBuilderLocal::getLink(const DSNodeHandle &node, unsigned LinkNo) {
   DSNodeHandle &Node = const_cast<DSNodeHandle&>(node);
   DSNodeHandle &Link = Node.getLink(LinkNo);
   if (Link.isNull()) {
@@ -285,8 +335,8 @@
 /// specified destination.  If the Value already points to a node, make sure to
 /// merge the two destinations together.
 ///
-void GraphBuilder::setDestTo(Value &V, const DSNodeHandle &NH) {
-  G.getNodeForValue(&V).mergeWith(NH);
+void GraphBuilderBase::setDestTo(Value &V, const DSNodeHandle &NH) {
+  getNodeForValue(&V).mergeWith(NH);
 }
 
 
@@ -297,26 +347,26 @@
 // PHINode - Make the scalar for the PHI node point to all of the things the
 // incoming values point to... which effectively causes them to be merged.
 //
-void GraphBuilder::visitPHINode(PHINode &PN) {
+void GraphBuilderLocal::visitPHINode(PHINode &PN) {
   if (!isa<PointerType>(PN.getType())) return; // Only pointer PHIs
 
-  DSNodeHandle &PNDest = G.getNodeForValue(&PN);
+  DSNodeHandle &PNDest = getNodeForValue(&PN);
   for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
     PNDest.mergeWith(getValueDest(*PN.getIncomingValue(i)));
 }
 
-void GraphBuilder::visitSelectInst(SelectInst &SI) {
+void GraphBuilderLocal::visitSelectInst(SelectInst &SI) {
   if (!isa<PointerType>(SI.getType()))
     return; // Only pointer Selects
 
-  DSNodeHandle &Dest = G.getNodeForValue(&SI);
+  DSNodeHandle &Dest = getNodeForValue(&SI);
   DSNodeHandle S1 = getValueDest(*SI.getOperand(1));
   DSNodeHandle S2 = getValueDest(*SI.getOperand(2));
   Dest.mergeWith(S1);
   Dest.mergeWith(S2);
 }
 
-void GraphBuilder::visitLoadInst(LoadInst &LI) {
+void GraphBuilderLocal::visitLoadInst(LoadInst &LI) {
   DSNodeHandle Ptr = getValueDest(*LI.getOperand(0));
 
   if (Ptr.isNull()) return; // Load from null
@@ -331,7 +381,7 @@
     setDestTo(LI, getLink(Ptr));
 }
 
-void GraphBuilder::visitStoreInst(StoreInst &SI) {
+void GraphBuilderLocal::visitStoreInst(StoreInst &SI) {
   const Type *StoredTy = SI.getOperand(0)->getType();
   DSNodeHandle Dest = getValueDest(*SI.getOperand(1));
   if (Dest.isNull()) return;
@@ -347,12 +397,12 @@
     Dest.addEdgeTo(getValueDest(*SI.getOperand(0)));
 }
 
-void GraphBuilder::visitReturnInst(ReturnInst &RI) {
+void GraphBuilderLocal::visitReturnInst(ReturnInst &RI) {
   if (RI.getNumOperands() && isa<PointerType>(RI.getOperand(0)->getType()))
-    G.getOrCreateReturnNodeFor(*FB).mergeWith(getValueDest(*RI.getOperand(0)));
+    RetNode.mergeWith(getValueDest(*RI.getOperand(0)));
 }
 
-void GraphBuilder::visitVAArgInst(VAArgInst &I) {
+void GraphBuilderLocal::visitVAArgInst(VAArgInst &I) {
   //FIXME: also updates the argument
   DSNodeHandle Ptr = getValueDest(*I.getOperand(0));
   if (Ptr.isNull()) return;
@@ -368,30 +418,30 @@
     setDestTo(I, getLink(Ptr));
 }
 
-void GraphBuilder::visitIntToPtrInst(IntToPtrInst &I) {
+void GraphBuilderLocal::visitIntToPtrInst(IntToPtrInst &I) {
 //  std::cerr << "cast in " << I.getParent()->getParent()->getName() << "\n";
 //  I.dump();
   setDestTo(I, createNode()->setUnknownMarker()->setIntToPtrMarker()); 
 }
 
-void GraphBuilder::visitPtrToIntInst(PtrToIntInst& I) {
+void GraphBuilderLocal::visitPtrToIntInst(PtrToIntInst& I) {
   if (DSNode* N = getValueDest(*I.getOperand(0)).getNode())
     N->setPtrToIntMarker();
 }
 
 
-void GraphBuilder::visitBitCastInst(BitCastInst &I) {
+void GraphBuilderLocal::visitBitCastInst(BitCastInst &I) {
   if (!isa<PointerType>(I.getType())) return; // Only pointers
   DSNodeHandle Ptr = getValueDest(*I.getOperand(0));
   if (Ptr.isNull()) return;
   setDestTo(I, Ptr);
 }
 
-void GraphBuilder::visitCmpInst(CmpInst &I) {
-  //Should this merge or not?  I don't think so.
+void GraphBuilderLocal::visitCmpInst(CmpInst &I) {
+  // TODO: must merge pointers
 }
 
-void GraphBuilder::visitGetElementPtrInst(User &GEP) {
+void GraphBuilderBase::visitGetElementPtrInst(User &GEP) {
   DSNodeHandle Value = getValueDest(*GEP.getOperand(0));
   if (Value.isNull())
     Value = createNode();
@@ -488,7 +538,7 @@
         // Variable index into a node.  We must merge all of the elements of the
         // sequential type here.
         if (isa<PointerType>(STy)) {
-          DEBUG(ferrs() << "Pointer indexing not handled yet!\n");
+          DEBUG(errs() << "Pointer indexing not handled yet!\n");
 	} else {
           const ArrayType *ATy = cast<ArrayType>(STy);
           unsigned ElSize = TD.getTypeAllocSize(CurTy);
@@ -537,7 +587,7 @@
     {
       if (G.getPoolDescriptorsMap().count(N) != 0)
         if (G.getPoolDescriptorsMap()[N]) {
-	  DEBUG(ferrs() << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n");
+	  DEBUG(errs() << "LLVA: GEP[" << 0 << "]: Pool for " << GEP.getName() << " is " << G.getPoolDescriptorsMap()[N]->getName() << "\n");
 	}
     }
   }
@@ -546,16 +596,16 @@
 }
 
 
-void GraphBuilder::visitCallInst(CallInst &CI) {
+void GraphBuilderLocal::visitCallInst(CallInst &CI) {
   visitCallSite(&CI);
 }
 
-void GraphBuilder::visitInvokeInst(InvokeInst &II) {
+void GraphBuilderLocal::visitInvokeInst(InvokeInst &II) {
   visitCallSite(&II);
 }
 
 /// returns true if the intrinsic is handled
-bool GraphBuilder::visitIntrinsic(CallSite CS, Function *F) {
+bool GraphBuilderLocal::visitIntrinsic(CallSite CS, Function *F) {
   switch (F->getIntrinsicID()) {
   case Intrinsic::vastart: {
     // Mark the memory written by the vastart intrinsic as incomplete
@@ -697,14 +747,14 @@
         return true;
     }
 
-    DEBUG(ferrs() << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n");
+    DEBUG(errs() << "[dsa:local] Unhandled intrinsic: " << F->getName() << "\n");
     assert(0 && "Unhandled intrinsic");
     return false;
   }
   }
 }
 
-void GraphBuilder::visitCallSite(CallSite CS) {
+void GraphBuilderLocal::visitCallSite(CallSite CS) {
   Value *Callee = CS.getCalledValue();
 
   // Special case handling of certain libc allocation functions here.
@@ -728,7 +778,7 @@
   if (!isa<Function>(Callee)) {
     CalleeNode = getValueDest(*Callee).getNode();
     if (CalleeNode == 0) {
-      DEBUG(ferrs() << "WARNING: Program is calling through a null pointer?\n" << *I);
+      DEBUG(errs() << "WARNING: Program is calling through a null pointer?\n" << *I);
       return;  // Calling a null pointer?
     }
   }
@@ -740,20 +790,21 @@
   for (CallSite::arg_iterator I = CS.arg_begin(), E = CS.arg_end(); I != E; ++I)
     if (isa<PointerType>((*I)->getType()))
       Args.push_back(getValueDest(**I));
+    else
+      Args.push_back(0);
 
   // Add a new function call entry...
   if (CalleeNode) {
-    G.getFunctionCalls().push_back(DSCallSite(CS, RetVal, CalleeNode, Args));
+    addDSCallSite(DSCallSite(CS, RetVal, CalleeNode, Args));
     DS->callee_site(CS.getInstruction());
-  }else
-    G.getFunctionCalls().push_back(DSCallSite(CS, RetVal, cast<Function>(Callee),
-                                              Args));
+  } else
+    addDSCallSite(DSCallSite(CS, RetVal, cast<Function>(Callee), Args));
 }
 
 // visitInstruction - For all other instruction types, if we have any arguments
 // that are of pointer type, make them have unknown composition bits, and merge
 // the nodes together.
-void GraphBuilder::visitInstruction(Instruction &Inst) {
+void GraphBuilderLocal::visitInstruction(Instruction &Inst) {
   DSNodeHandle CurNode;
   if (isa<PointerType>(Inst.getType()))
     CurNode = getValueDest(Inst);
@@ -765,6 +816,13 @@
     N->setUnknownMarker();
 }
 
+void GraphBuilderLocal::visitExtractValueInst(ExtractValueInst &I) {
+  assert(!isa<PointerType>(I.getType()) && "ExtractValue not supported");
+}
+
+void GraphBuilderLocal::visitInsertValueInst(InsertValueInst &I) {
+  assert(!isa<PointerType>((*(I.op_begin()))->getType()) && "InsertValue not supported");
+}
 
 
 //===----------------------------------------------------------------------===//
@@ -773,7 +831,7 @@
 
 // MergeConstantInitIntoNode - Merge the specified constant into the node
 // pointed to by NH.
-void GraphBuilder::MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C) {
+void GraphBuilderGlobal::MergeConstantInitIntoNode(DSNodeHandle &NH, const Type* Ty, Constant *C) {
   // Ensure a type-record exists...
   DSNode *NHN = NH.getNode();
   NHN->mergeTypeInfo(Ty, NH.getOffset());
@@ -814,13 +872,14 @@
   }
 }
 
-void GraphBuilder::mergeInGlobalInitializer(GlobalVariable *GV) {
+void GraphBuilderGlobal::mergeInGlobalInitializer(GlobalVariable *GV) {
   assert(!GV->isDeclaration() && "Cannot merge in external global!");
   // Get a node handle to the global node and merge the initializer into it.
   DSNodeHandle NH = getValueDest(*GV);
   MergeConstantInitIntoNode(NH, GV->getType()->getElementType(), GV->getInitializer());
 }
 
+
 char LocalDataStructures::ID;
 
 bool LocalDataStructures::runOnModule(Module &M) {
@@ -828,7 +887,7 @@
 
   // First step, build the globals graph.
   {
-    GraphBuilder GGB(*GlobalsGraph);
+    GraphBuilderGlobal GGB(GlobalsGraph);
 
     // Add initializers for all of the globals to the globals graph.
     for (Module::global_iterator I = M.global_begin(), E = M.global_end();
@@ -849,7 +908,7 @@
   for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I)
     if (!I->isDeclaration()) {
       DSGraph* G = new DSGraph(GlobalECs, getTargetData(), GlobalsGraph);
-      GraphBuilder GGB(*I, *G, *this);
+      GraphBuilderLocal GGB(*I, G->getOrCreateReturnNodeFor(*I), G, *this);
       G->getAuxFunctionCalls() = G->getFunctionCalls();
       setDSGraph(*I, G);
       propagateUnknownFlag(G);

Modified: poolalloc/trunk/lib/rDSA/Makefile
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Makefile?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/Makefile (original)
+++ poolalloc/trunk/lib/rDSA/Makefile Tue Aug  4 19:30:22 2009
@@ -10,7 +10,7 @@
 LEVEL = ../..
 BUILD_RELINKED=1
 SHARED_LIBRARY=1
-LIBRARYNAME = LLVMDataStructure
+LIBRARYNAME = rDSA
 
 include $(LEVEL)/Makefile.common
 

Copied: poolalloc/trunk/lib/rDSA/Printer.cpp (from r78088, poolalloc/trunk/lib/DSA/Printer.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Printer.cpp?p2=poolalloc/trunk/lib/rDSA/Printer.cpp&p1=poolalloc/trunk/lib/DSA/Printer.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/Printer.cpp (original)
+++ poolalloc/trunk/lib/rDSA/Printer.cpp Tue Aug  4 19:30:22 2009
@@ -13,8 +13,8 @@
 
 #define DEBUG_TYPE "dsgraph-printer"
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "dsa/DSGraphTraits.h"
 #include "llvm/Module.h"
 #include "llvm/Constants.h"
@@ -339,17 +339,16 @@
     << "] nodes total" << std::endl;
 }
 
-
 void DataStructures::dumpCallGraph() const {
   for(  ActualCalleesTy::const_iterator ii = ActualCallees.begin(), ee = ActualCallees.end();
         ii != ee; ++ii) {
-    if (ii->first) ferrs() << ii->first->getParent()->getParent()->getName() << " ";
-    ferrs() << ii->first << ": [";
+    if (ii->first) errs() << ii->first->getParent()->getParent()->getName() << " ";
+    errs() << ii->first << ": [";
     for (callee_iterator cbi = ii->second.begin(), cbe = ii->second.end();
          cbi != cbe; ++cbi) {
-      ferrs() << (*cbi)->getName() << " ";
+      errs() << (*cbi)->getName() << " ";
     }
-    ferrs() << "]\n";
+    errs() << "]\n";
     if (ii->first) ii->first->dump();
   }
 }

Copied: poolalloc/trunk/lib/rDSA/StdLibPass.cpp (from r78088, poolalloc/trunk/lib/DSA/StdLibPass.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/StdLibPass.cpp?p2=poolalloc/trunk/lib/rDSA/StdLibPass.cpp&p1=poolalloc/trunk/lib/DSA/StdLibPass.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/StdLibPass.cpp (original)
+++ poolalloc/trunk/lib/rDSA/StdLibPass.cpp Tue Aug  4 19:30:22 2009
@@ -10,8 +10,8 @@
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/Statistic.h"
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Instructions.h"
@@ -183,7 +183,7 @@
       if (CI->getOperand(0) == F) {
         DSGraph* Graph = getDSGraph(*CI->getParent()->getParent());
         //delete the call
-        DEBUG(ferrs() << "Removing " << F->getNameStr() << " from " 
+        DEBUG(errs() << "Removing " << F->getNameStr() << " from " 
 	      << CI->getParent()->getParent()->getNameStr() << "\n");
         Graph->removeFunctionCalls(*F);
       }

Modified: poolalloc/trunk/lib/rDSA/Steensgaard.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/Steensgaard.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/Steensgaard.cpp (original)
+++ poolalloc/trunk/lib/rDSA/Steensgaard.cpp Tue Aug  4 19:30:22 2009
@@ -13,8 +13,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Module.h"

Modified: poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp?rev=78134&r1=78082&r2=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp (original)
+++ poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp Tue Aug  4 19:30:22 2009
@@ -14,8 +14,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "dsa/DataStructure.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DataStructure.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Analysis/AliasAnalysis.h"
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Module.h"

Copied: poolalloc/trunk/lib/rDSA/TopDownClosure.cpp (from r78088, poolalloc/trunk/lib/DSA/TopDownClosure.cpp)
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/rDSA/TopDownClosure.cpp?p2=poolalloc/trunk/lib/rDSA/TopDownClosure.cpp&p1=poolalloc/trunk/lib/DSA/TopDownClosure.cpp&r1=78088&r2=78134&rev=78134&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/TopDownClosure.cpp (original)
+++ poolalloc/trunk/lib/rDSA/TopDownClosure.cpp Tue Aug  4 19:30:22 2009
@@ -15,10 +15,10 @@
 //===----------------------------------------------------------------------===//
 #define DEBUG_TYPE "td_dsa"
 
-#include "dsa/DataStructure.h"
+#include "rdsa/DataStructure.h"
 #include "llvm/Module.h"
 #include "llvm/DerivedTypes.h"
-#include "dsa/DSGraph.h"
+#include "rdsa/DSGraph.h"
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/FormattedStream.h"
 #include "llvm/Support/Timer.h"
@@ -198,7 +198,7 @@
       RC.getClonedNH(GG->getNodeForValue(*GI));
   }
 
-  DEBUG(ferrs() << "[TD] Inlining callers into '" 
+  DEBUG(errs() << "[TD] Inlining callers into '" 
 	<< DSG->getFunctionNames() << "'\n");
 
   // Iteratively inline caller graphs into this graph.
@@ -215,15 +215,15 @@
     do {
       const DSCallSite &CS = *EdgesFromCaller.back().CS;
       const Function &CF = *EdgesFromCaller.back().CalledFunction;
-      DEBUG(ferrs() << "   [TD] Inlining graph into Fn '" 
+      DEBUG(errs() << "   [TD] Inlining graph into Fn '" 
 	    << CF.getNameStr() << "' from ");
       if (CallerGraph->getReturnNodes().empty()) {
-        DEBUG(ferrs() << "SYNTHESIZED INDIRECT GRAPH");
+        DEBUG(errs() << "SYNTHESIZED INDIRECT GRAPH");
       } else {
-        DEBUG(ferrs() << "Fn '" << CS.getCallSite().getInstruction()->
+        DEBUG(errs() << "Fn '" << CS.getCallSite().getInstruction()->
 	      getParent()->getParent()->getNameStr() << "'");
       }
-      DEBUG(ferrs() << ": " << CF.getFunctionType()->getNumParams() 
+      DEBUG(errs() << ": " << CF.getFunctionType()->getNumParams() 
 	    << " args\n");
 
       // Get the formal argument and return nodes for the called function and
@@ -339,7 +339,7 @@
 
     // If we already have this graph, recycle it.
     if (IndCallRecI != IndCallMap.end() && IndCallRecI->first == Callees) {
-      DEBUG(ferrs() << "  [TD] *** Reuse of indcall graph for " << Callees.size()
+      DEBUG(errs() << "  [TD] *** Reuse of indcall graph for " << Callees.size()
 	    << " callees!\n");
       IndCallGraph = IndCallRecI->second;
     } else {





More information about the llvm-commits mailing list