[llvm-commits] [poolalloc] r81266 - in /poolalloc/trunk: include/rdsa/DSFlags.h include/rdsa/DSGraph.h include/rdsa/DSGraphTraits.h include/rdsa/DSNode.h lib/rDSA/BottomUpClosure.cpp lib/rDSA/CompleteBottomUp.cpp lib/rDSA/DataStructure.cpp lib/rDSA/DataStructureAA.cpp lib/rDSA/DataStructureOpt.cpp lib/rDSA/DataStructureStats.cpp lib/rDSA/Local.cpp lib/rDSA/Printer.cpp lib/rDSA/StdLibPass.cpp lib/rDSA/SteensgaardAA.cpp lib/rDSA/TopDownClosure.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Tue Sep 8 16:06:16 PDT 2009


Author: alenhar2
Date: Tue Sep  8 18:06:16 2009
New Revision: 81266

URL: http://llvm.org/viewvc/llvm-project?rev=81266&view=rev
Log:
Factor out flags for later side use

Added:
    poolalloc/trunk/include/rdsa/DSFlags.h
Modified:
    poolalloc/trunk/include/rdsa/DSGraph.h
    poolalloc/trunk/include/rdsa/DSGraphTraits.h
    poolalloc/trunk/include/rdsa/DSNode.h
    poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp
    poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp
    poolalloc/trunk/lib/rDSA/DataStructure.cpp
    poolalloc/trunk/lib/rDSA/DataStructureAA.cpp
    poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp
    poolalloc/trunk/lib/rDSA/DataStructureStats.cpp
    poolalloc/trunk/lib/rDSA/Local.cpp
    poolalloc/trunk/lib/rDSA/Printer.cpp
    poolalloc/trunk/lib/rDSA/StdLibPass.cpp
    poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp
    poolalloc/trunk/lib/rDSA/TopDownClosure.cpp

Added: poolalloc/trunk/include/rdsa/DSFlags.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/rdsa/DSFlags.h?rev=81266&view=auto

==============================================================================
--- poolalloc/trunk/include/rdsa/DSFlags.h (added)
+++ poolalloc/trunk/include/rdsa/DSFlags.h Tue Sep  8 18:06:16 2009
@@ -0,0 +1,138 @@
+class DSFlags {
+  
+ public:
+  enum NodeTy {
+    ShadowNode         = 0,         // Nothing is known about this node...
+    AllocaNode         = 1 <<  0,   // This node was allocated with alloca
+    HeapNode           = 1 <<  1,   // This node was allocated with malloc
+    GlobalNode         = 1 <<  2,   // This node was allocated by a global
+    ExternGlobalNode   = 1 <<  3,   // Tyis node was allocated by an extern global
+    FunctionNode       = 1 <<  4,   // This node contains a function
+    ExternFunctionNode = 1 <<  5,   // This node contains an extern func
+    IntToPtrNode       = 1 <<  7,   // This node comes from an int cast
+    PtrToIntNode       = 1 <<  8,   // This node escapes to an int cast
+    EscapedNode        = 1 <<  9,   // This node escapes to external code
+    ModifiedNode       = 1 << 10,   // This node is modified in this context
+    ReadNode           = 1 << 11,   // This node is read in this context
+    ArrayNode          = 1 << 12,   // This node is treated like an array
+
+    UnknownNode        = 1 << 13,   // This node points to unknown allocated memory
+    IncompleteNode     = 1 << 14,   // This node may not be complete
+        
+    //#ifndef NDEBUG
+    DeadNode           = 1 << 15    // This node is dead and should not be pointed to
+    //#endif
+  };
+  
+ private:
+  /// NodeType - A union of the above bits.  "Shadow" nodes do not add any flags
+  /// to the nodes in the data structure graph, so it is possible to have nodes
+  /// with a value of 0 for their NodeType.
+  ///
+  unsigned short NodeType;
+  
+ public:
+  /// maskNodeTypes - Apply a mask to the node types bitfield.
+  ///
+  void maskFlags(unsigned short Mask) {
+    NodeType &= Mask;
+  }
+  
+  void mergeFlags(unsigned short RHS) {
+    NodeType |= RHS;
+  }
+
+  unsigned short getFlags() const {
+    return NodeType;
+  }
+
+  bool isAllocaNode()         const { return NodeType & AllocaNode;       }
+  bool isHeapNode()           const { return NodeType & HeapNode;         }
+  bool isGlobalNode()         const { return NodeType & GlobalNode;       }
+  bool isExternGlobalNode()   const { return NodeType & ExternGlobalNode; }
+  bool isFunctionNode()       const { return NodeType & FunctionNode;     }
+  bool isExternFunctionNode() const { return NodeType & FunctionNode;     }
+  bool isIntToPtrNode()       const { return NodeType & IntToPtrNode;     }
+  bool isPtrToIntNode()       const { return NodeType & PtrToIntNode;     }
+  bool isEscapedNode()        const { return NodeType & EscapedNode;      }
+  bool isModifiedNode()       const { return NodeType & ModifiedNode;     }
+  bool isReadNode()           const { return NodeType & ReadNode;         }
+  bool isArrayNode()          const { return NodeType & ArrayNode;        }
+  bool isUnknownNode()        const { return NodeType & UnknownNode;      }
+  bool isIncompleteNode()     const { return NodeType & IncompleteNode;   }
+  bool isCompleteNode()       const { return !isIncompleteNode();         }
+  bool isDeadNode()           const { return NodeType & DeadNode;         }
+
+  bool isComputedUnknownNode() const {
+    return isIntToPtrNode();
+  }
+
+  void setAllocaNode()         { NodeType |= AllocaNode; }
+  void setHeapNode()           { NodeType |= HeapNode; }
+  void setGlobalNode()         { NodeType |= GlobalNode; }
+  void setExternGlobalNode()   { NodeType |= ExternGlobalNode; }
+  void setFunctionNode()       { NodeType |= FunctionNode; }
+  void setExternFunctionNode() { NodeType |= ExternFunctionNode; }
+  void setIntToPtrNode()       { NodeType |= IntToPtrNode; }
+  void setPtrToIntNode()       { NodeType |= PtrToIntNode; }
+  void setEscapedNode()        { NodeType |= EscapedNode; }
+  void setModifiedNode()       { NodeType |= ModifiedNode; }
+  void setReadNode()           { NodeType |= ReadNode; }
+  void setArrayNode()          { NodeType |= ArrayNode; }
+  
+  void setUnknownNode()        { NodeType |= UnknownNode; }
+  void setIncompleteNode()     { NodeType |= IncompleteNode; }
+  void setDeadNode()           { NodeType |= DeadNode; }
+  
+  // template to avoid std::string include
+  template<class STR>
+  void appendString(STR& str) const {
+    if (isAllocaNode()) {
+      str += "S";
+    }
+    if (isHeapNode()) {
+      str += "H";
+    }
+    if (isGlobalNode()) {
+      str += "Gl";
+    }
+    if (isExternGlobalNode()) {
+      str += "Ge";
+    }
+    if (isFunctionNode()) {
+      str += "Fl";
+    }
+    if (isExternFunctionNode()) {
+      str += "Fe";
+    }
+    if (isIntToPtrNode()) {
+      str += "P";
+    }
+    if (isPtrToIntNode()) {
+      str += "2";
+    }
+    if (isEscapedNode()) {
+      str += "E";
+    }
+    if (isModifiedNode()) {
+      str += "M";
+    }
+    if (isReadNode()) {
+      str += "R";
+    }
+    if (isArrayNode()) {
+      str += "A";
+    }
+    if (isUnknownNode()) {
+      str += "U";
+    }
+    if (isIncompleteNode()) {
+      str += "I";
+    }
+    if (isDeadNode()) {
+      str += "<dead>";
+    }
+  }
+
+  DSFlags() :NodeType(0) {}
+};

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

==============================================================================
--- poolalloc/trunk/include/rdsa/DSGraph.h (original)
+++ poolalloc/trunk/include/rdsa/DSGraph.h Tue Sep  8 18:06:16 2009
@@ -440,9 +440,9 @@
   ///
   void maskNodeTypes(unsigned Mask) {
     for (node_iterator I = node_begin(), E = node_end(); I != E; ++I)
-      I->maskNodeTypes(Mask);
+      I->NodeType.maskFlags(Mask);
   }
-  void maskIncompleteMarkers() { maskNodeTypes(~DSNode::IncompleteNode); }
+  void maskIncompleteMarkers() { maskNodeTypes(~DSFlags::IncompleteNode); }
 
   // markIncompleteNodes - Traverse the graph, identifying nodes that may be
   // modified by other functions that have not been resolved yet.  This marks

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

==============================================================================
--- poolalloc/trunk/include/rdsa/DSGraphTraits.h (original)
+++ poolalloc/trunk/include/rdsa/DSGraphTraits.h Tue Sep  8 18:06:16 2009
@@ -36,7 +36,7 @@
     if (N != 0) {
       Offset = N->getNumLinks();
       if (Offset == 0 && Node->getForwardNode() &&
-          Node->isDeadNode())        // Model Forward link
+          Node->NodeType.isDeadNode())        // Model Forward link
         Offset += 1;
     } else {
       Offset = 0;
@@ -58,7 +58,7 @@
   }
 
   pointer operator*() const {
-    if (Node->isDeadNode())
+    if (Node->NodeType.isDeadNode())
       return Node->getForwardNode();
     else
       return Node->getLink(Offset).getNode();

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

==============================================================================
--- poolalloc/trunk/include/rdsa/DSNode.h (original)
+++ poolalloc/trunk/include/rdsa/DSNode.h Tue Sep  8 18:06:16 2009
@@ -15,6 +15,7 @@
 #define LLVM_ANALYSIS_DSNODE_H
 
 #include "rdsa/DSSupport.h"
+#include "rdsa/DSFlags.h"
 #include "llvm/Support/Streams.h"
 #include "poolalloc/ADT/HashExtras.h"
 
@@ -107,13 +108,8 @@
     Composition = AllocaNode | HeapNode | GlobalNode | UnknownNode
   };
 
-  /// NodeType - A union of the above bits.  "Shadow" nodes do not add any flags
-  /// to the nodes in the data structure graph, so it is possible to have nodes
-  /// with a value of 0 for their NodeType.
-  ///
-private:
-  unsigned short NodeType;
 public:
+  DSFlags NodeType;
 
   /// DSNode ctor - Create a node of the specified type, inserting it into the
   /// specified graph.
@@ -155,8 +151,6 @@
   ///
   const Type *getType() const { return Ty; }
 
-  bool isArray() const { return NodeType & ArrayNode; }
-
   /// hasNoReferrers - Return true if nothing is pointing to this node at all.
   ///
   bool hasNoReferrers() const { return getNumReferrers() == 0; }
@@ -319,62 +313,15 @@
   globals_iterator globals_begin() const { return Globals.begin(); }
   globals_iterator globals_end() const { return Globals.end(); }
 
-
-  /// maskNodeTypes - Apply a mask to the node types bitfield.
-  ///
-  void maskNodeTypes(unsigned Mask) {
-    NodeType &= Mask;
-  }
-
-  void mergeNodeFlags(unsigned RHS) {
-    NodeType |= RHS;
-  }
-
   /// getNodeFlags - Return all of the flags set on the node.  If the DEAD flag
   /// is set, hide it from the caller.
   ///
-  unsigned getNodeFlags() const { return NodeType & ~DeadNode; }
-
-  /// clearNodeFlags - Useful for completely resetting a node, 
-  /// used in external recognizers
-  DSNode* clearNodeFlags() { NodeType = 0; return this; }
-
-  bool isAllocaNode()     const { return NodeType & AllocaNode;    }
-  bool isHeapNode()       const { return NodeType & HeapNode;      }
-  bool isGlobalNode()     const { return NodeType & GlobalNode;    }
-  bool isUnknownNode()    const { return NodeType & UnknownNode;   }
-  bool isModifiedNode()   const { return NodeType & ModifiedNode;  }
-  bool isReadNode()       const { return NodeType & ReadNode;      }
-  bool isArrayNode()      const { return NodeType & ArrayNode;     }
-  bool isIncompleteNode() const { return NodeType & IncompleteNode;}
-  bool isCompleteNode()   const { return !isIncompleteNode();      }
-  bool isDeadNode()       const { return NodeType & DeadNode;      }
-  bool isExternalNode()   const { return NodeType & ExternalNode;  }
-  bool isIntToPtrNode()   const { return NodeType & IntToPtrNode;  }
-  bool isPtrToIntNode()   const { return NodeType & PtrToIntNode;  }
-  bool isVAStartNode()    const { return NodeType & VAStartNode;   }
-  bool isFunctionNode()   const { return NodeType & FunctionNode;  }
-  bool isExternFunctionNode() const { return NodeType & ExternFunctionNode; }
-
-  DSNode* setAllocaMarker()     { NodeType |= AllocaNode;     return this; }
-  DSNode* setHeapMarker()       { NodeType |= HeapNode;       return this; }
-  DSNode* setGlobalMarker()     { NodeType |= GlobalNode;     return this; }
-  DSNode* setUnknownMarker()    { NodeType |= UnknownNode;    return this; }
-  DSNode* setModifiedMarker()   { NodeType |= ModifiedNode;   return this; }
-  DSNode* setReadMarker()       { NodeType |= ReadNode;       return this; }
-  DSNode* setArrayMarker()      { NodeType |= ArrayNode;      return this; }
-  DSNode* setIncompleteMarker() { NodeType |= IncompleteNode; return this; }
-  DSNode* setExternalMarker()   { NodeType |= ExternalNode;   return this; }
-  DSNode* setIntToPtrMarker()   { NodeType |= IntToPtrNode;   return this; }
-  DSNode* setPtrToIntMarker()   { NodeType |= PtrToIntNode;   return this; }
-  DSNode* setVAStartMarker()    { NodeType |= VAStartNode;    return this; }
-  DSNode* setFunctionMarker()   { NodeType |= FunctionNode;   return this; }
-  DSNode* setExternFunctionMarker() { NodeType |= ExternFunctionNode; return this; }
+  unsigned getNodeFlags() const { return NodeType.getFlags() & ~DSFlags::DeadNode; }
 
   void makeNodeDead() {
     Globals.clear();
     assert(hasNoReferrers() && "Dead node shouldn't have refs!");
-    NodeType = DeadNode;
+    NodeType.setDeadNode();
   }
 
   /// forwardNode - Mark this node as being obsolete, and all references to it
@@ -498,7 +445,7 @@
       Offset = 0;
     }
   }
-  assert(!N || ((N->NodeType & DSNode::DeadNode) == 0));
+  assert(!N || !N->NodeType.isDeadNode());
   assert((!N || Offset < N->Size || (N->Size == 0 && Offset == 0) ||
           N->isForwarding()) && "Node handle offset out of range!");
   return *this;

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp (original)
+++ poolalloc/trunk/lib/rDSA/BottomUpClosure.cpp Tue Sep  8 18:06:16 2009
@@ -15,6 +15,7 @@
 //===----------------------------------------------------------------------===//
 
 #define DEBUG_TYPE "dsa-bu"
+
 #include "rdsa/DataStructure.h"
 #include "rdsa/DSGraph.h"
 #include "llvm/Module.h"
@@ -126,7 +127,7 @@
   std::set<DSCallSite> GoodCalls, BadCalls;
   for (DSGraph::afc_iterator ii = GlobalsGraph->afc_begin(), 
          ee = GlobalsGraph->afc_end(); ii != ee; ++ii)
-    if (ii->isDirectCall() || ii->getCalleeNode()->isExternFunctionNode())
+    if (ii->isDirectCall() || ii->getCalleeNode()->NodeType.isExternFunctionNode())
       BadCalls.insert(*ii);
     else
       GoodCalls.insert(*ii);
@@ -156,9 +157,9 @@
   if (CS.isDirectCall()) {
     if (!CS.getCalleeFunc()->isDeclaration())
       Callees.push_back(CS.getCalleeFunc());
-  } else if (!CS.getCalleeNode()->isIncompleteNode()) {
+  } else if (!CS.getCalleeNode()->NodeType.isIncompleteNode()) {
     // Get all callees.
-    if (!CS.getCalleeNode()->isExternFunctionNode())
+    if (!CS.getCalleeNode()->NodeType.isExternFunctionNode())
       CS.getCalleeNode()->addFullFunctionList(Callees);
   }
 }

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp (original)
+++ poolalloc/trunk/lib/rDSA/CompleteBottomUp.cpp Tue Sep  8 18:06:16 2009
@@ -56,7 +56,7 @@
       DSGraph* G = getOrFetchDSGraph((*ii)->getParent()->getParent());
       for ( ; csi != cse; ++csi) {
         G->getNodeForValue(*csi).mergeWith(G->getNodeForValue((*ii)->getOperand(0)));
-        G->getNodeForValue((*ii)->getOperand(0)).getNode()->setGlobalMarker();
+        G->getNodeForValue((*ii)->getOperand(0)).getNode()->NodeType.setGlobalNode();
         G->getNodeForValue((*ii)->getOperand(0)).getNode()->addGlobal(*csi);
       }
     }

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructure.cpp Tue Sep  8 18:06:16 2009
@@ -120,7 +120,7 @@
 //===----------------------------------------------------------------------===//
 
 DSNode::DSNode(const Type *T, DSGraph *G)
-  : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::getVoidTy(getGlobalContext())), NodeType(0) {
+  : NumReferrers(0), Size(0), ParentGraph(G), Ty(Type::getVoidTy(getGlobalContext())) {
   // Add the type entry if it is specified...
   if (T) mergeTypeInfo(T, 0);
   if (G) G->addNode(this);
@@ -142,17 +142,6 @@
 DSNode::~DSNode() {
   dropAllReferences();
   assert(hasNoReferrers() && "Referrers to dead node exist!");
-
-#ifdef LLVA_KERNEL
-  //
-  // Remove all references to this node from the Pool Descriptor Map.
-  //
-  DOUT << "LLVA: Removing " << this << "\n";
-  if (ParentGraph) {
-    hash_map<const DSNode *, MetaPoolHandle*> &pdm=ParentGraph->getPoolDescriptorsMap();
-    pdm.erase (this);
-  }
-#endif
 }
 
 /// getTargetData - Get the target data object used to construct this node.
@@ -163,8 +152,8 @@
 
 void DSNode::assertOK() const {
   assert((Ty != Type::getVoidTy(getGlobalContext()) ||
-          (Ty == Type::getVoidTy(getGlobalContext()) && (Size == 0 ||
-                                  (NodeType & DSNode::ArrayNode)))) &&
+          (Ty == Type::getVoidTy(getGlobalContext()) 
+           && (Size == 0 || NodeType.isArrayNode()))) &&
          "Node not OK!");
 
   assert(ParentGraph && "Node has no parent?");
@@ -185,7 +174,7 @@
   assert((Offset < To->Size || (Offset == To->Size && Offset == 0)) &&
          "Forwarded offset is wrong!");
   ForwardNH.setTo(To, Offset);
-  NodeType = DeadNode;
+  NodeType.setDeadNode();
   Size = 0;
   Ty = Type::getVoidTy(getGlobalContext());
 
@@ -208,7 +197,7 @@
 
   if (I == Globals.end() || *I != GV) {
     Globals.insert(I, GV);
-    NodeType |= GlobalNode;
+    NodeType.setGlobalNode();
   }
 }
 
@@ -217,9 +206,10 @@
 /// it does not already have it.
 ///
 void DSNode::addFunction(const Function* FV) {
-  setFunctionMarker();
   if (FV->isDeclaration())
-    setExternFunctionMarker();
+    NodeType.setExternFunctionNode();
+  else
+    NodeType.setFunctionNode();
   addGlobal(FV);
 }
 
@@ -245,7 +235,7 @@
   // If this node has a size that is <= 1, we don't need to create a forwarding
   // node.
   if (getSize() <= 1) {
-    NodeType |= DSNode::ArrayNode;
+    NodeType.setArrayNode();
     Ty = Type::getVoidTy(getGlobalContext());
     Size = 1;
     assert(Links.size() <= 1 && "Size is 1, but has more links?");
@@ -255,24 +245,12 @@
     // some referrers may have an offset that is > 0.  By forcing them to
     // forward, the forwarder has the opportunity to correct the offset.
     DSNode *DestNode = new DSNode(0, ParentGraph);
-    DestNode->NodeType = NodeType|DSNode::ArrayNode;
+    DestNode->NodeType = NodeType;
+    DestNode->NodeType.setArrayNode();
     DestNode->Ty = Type::getVoidTy(getGlobalContext());
     DestNode->Size = 1;
     DestNode->Globals.swap(Globals);
     
-    //    DOUT << "LLVA: foldNode: " << this << " becomes " << DestNode << "\n";
-#ifdef LLVA_KERNEL
-    //Again we have created a new DSNode, we need to fill in the
-    // pool desc map appropriately
-    assert(ParentGraph && "parent graph is not null \n"); 
-    hash_map<const DSNode *, MetaPoolHandle*> &pdm = ParentGraph->getPoolDescriptorsMap();
-    if (pdm.count(this) > 0) {
-      pdm[DestNode] = pdm[this];
-    } else {
-      //do nothing 
-    }
-#endif    
-
     // Start forwarding to the destination node...
     forwardNode(DestNode, 0);
 
@@ -298,7 +276,7 @@
 /// all of the field sensitivity that may be present in the node.
 ///
 bool DSNode::isNodeCompletelyFolded() const {
-  return getSize() == 1 && Ty == Type::getVoidTy(getGlobalContext()) && isArray();
+  return getSize() == 1 && Ty == Type::getVoidTy(getGlobalContext()) && NodeType.isArrayNode();
 }
 
 /// addFullGlobalsList - Compute the full set of global values that are
@@ -477,10 +455,10 @@
   //  Size = 1, Ty = Void, Array = 1: The node is collapsed
   //  Otherwise, sizeof(Ty) = Size
   //
-  assert(((Size == 0 && Ty == Type::getVoidTy(getGlobalContext()) && !isArray()) ||
-          (Size == 0 && !Ty->isSized() && !isArray()) ||
-          (Size == 1 && Ty == Type::getVoidTy(getGlobalContext()) && isArray()) ||
-          (Size == 0 && !Ty->isSized() && !isArray()) ||
+  assert(((Size == 0 && Ty == Type::getVoidTy(getGlobalContext()) && !NodeType.isArrayNode()) ||
+          (Size == 0 && !Ty->isSized() && !NodeType.isArrayNode()) ||
+          (Size == 1 && Ty == Type::getVoidTy(getGlobalContext()) && NodeType.isArrayNode()) ||
+          (Size == 0 && !Ty->isSized() && !NodeType.isArrayNode()) ||
           (TD.getTypeAllocSize(Ty) == Size)) &&
          "Size member of DSNode doesn't match the type structure!");
   assert(NewTy != Type::getVoidTy(getGlobalContext()) && "Cannot merge void type into DSNode!");
@@ -513,7 +491,7 @@
   if (Ty == Type::getVoidTy(getGlobalContext())) {
     // If this is the first type that this node has seen, just accept it without
     // question....
-    assert(Offset == 0 && !isArray() &&
+    assert(Offset == 0 && !NodeType.isArrayNode() &&
            "Cannot have an offset into a void node!");
 
     // If this node would have to have an unreasonable number of fields, just
@@ -526,8 +504,8 @@
     }
 
     Ty = NewTy;
-    NodeType &= ~ArrayNode;
-    if (WillBeArray) NodeType |= ArrayNode;
+    NodeType.maskFlags(~DSFlags::ArrayNode);
+    if (WillBeArray) NodeType.setArrayNode();
     Size = NewTySize;
 
     // Calculate the number of outgoing links from this node.
@@ -539,7 +517,7 @@
   if (Offset+NewTySize > Size) {
     // It is illegal to grow this node if we have treated it as an array of
     // objects...
-    if (isArray()) {
+    if (NodeType.isArrayNode()) {
       if (FoldIfIncompatible) foldNodeCompletely();
       return true;
     }
@@ -623,8 +601,8 @@
 
     const Type *OldTy = Ty;
     Ty = NewTy;
-    NodeType &= ~ArrayNode;
-    if (WillBeArray) NodeType |= ArrayNode;
+    NodeType.maskFlags(~DSFlags::ArrayNode);
+    if (WillBeArray) NodeType.setArrayNode();
     Size = NewTySize;
 
     // Must grow links to be the appropriate size...
@@ -687,7 +665,7 @@
   // just require each element in the node to be compatible.
   if (NewTySize <= SubTypeSize && NewTySize && NewTySize < 256 &&
       SubTypeSize && SubTypeSize < 256 &&
-      ElementTypesAreCompatible(NewTy, SubType, !isArray(), TD))
+      ElementTypesAreCompatible(NewTy, SubType, !NodeType.isArrayNode(), TD))
     return false;
 
   // Okay, so we found the leader type at the offset requested.  Search the list
@@ -843,63 +821,11 @@
     }
 #endif
   }
-#ifdef LLVA_KERNEL
-  DSNode *currNode  = CurNodeH.getNode();
-  DSNode *NNode  = NH.getNode();
-  DSGraph *pGraph =  currNode->getParentGraph();
-  assert((pGraph == NNode->getParentGraph()) && "LLVA_KERNEL : merging nodes in two different graphs?");
-  //get the pooldescriptor map
-  hash_map<const DSNode *, MetaPoolHandle*> &pdm = pGraph->getPoolDescriptorsMap();
-  if (pdm.count(currNode) == 0) {
-    if (pdm.count(NNode) == 0) {
-      //do nothing  (common case)
-    } else {
-      if (pdm[NNode]) {
-        DOUT << "LLVA: 1: currNode (" << currNode << ") becomes " << pdm[NNode]->getName() << "(" << NNode << ")\n";
-        pdm[currNode] = pdm[NNode];
-      }
-    }
-  } else {
-    if (pdm.count(NNode) == 0) {
-#if 1
-      //
-      // FIXME:
-      //  Verify that this is correct.  I believe it is; it seems to make sense
-      //  since either node can be used after the merge.
-      //
-      DOUT << "LLVA: MergeNodes: currnode has something, newnode has nothing\n";
-      DOUT << "LLVA: 2: currNode (" << currNode << ") becomes <no name>"
-           << "(" << NNode << ")\n";
-      pdm[NNode] = pdm[currNode];
-#endif
-      //do nothing 
-    } else {
-      if (pdm[currNode] != pdm[NNode]) {
-	//The following is commented because pdm[..] could be null!
-	//std::cerr << "LLVA: OldPool: " << pdm[currNode]->getName() << "("
-        //                       << pdm[currNode] << ") "
-	//          << " NewPool: "      << pdm[NNode]->getName() << "("
-	//                               << pdm[NNode] << ")" << std::endl;
-        pdm[NNode]->merge(pdm[currNode]);
-        /*
-        Value *currN = pdm[currNode]->getMetaPoolValue();
-        Value *NN = pdm[NNode]->getMetaPoolValue();
-        if (currN != NN) {
-          std::cerr << "LLVA: Two Pools for one DSNode\n";
-          currN->replaceAllUsesWith(NN);
-          pdm[currNode]->merge(pdm[NNode]);
-        } else {
-          //The nodes are same
-        }
-        */
-      }
-    }
-  }
-#endif  
+
   // Merge the type entries of the two nodes together...
   if (NH.getNode()->Ty != Type::getVoidTy(getGlobalContext()))
     CurNodeH.getNode()->mergeTypeInfo(NH.getNode()->Ty, NOffset);
-  assert(!CurNodeH.getNode()->isDeadNode());
+  assert(!CurNodeH.getNode()->NodeType.isDeadNode());
 
   // If we are merging a node with a completely folded node, then both nodes are
   // now completely folded.
@@ -924,14 +850,14 @@
 
   DSNode *N = NH.getNode();
   if (CurNodeH.getNode() == N || N == 0) return;
-  assert(!CurNodeH.getNode()->isDeadNode());
+  assert(!CurNodeH.getNode()->NodeType.isDeadNode());
 
   // Merge the NodeType information.
-  CurNodeH.getNode()->NodeType |= N->NodeType;
+  CurNodeH.getNode()->NodeType.mergeFlags(N->NodeType.getFlags());
 
   // Start forwarding to the new node!
   N->forwardNode(CurNodeH.getNode(), NOffset);
-  assert(!CurNodeH.getNode()->isDeadNode());
+  assert(!CurNodeH.getNode()->NodeType.isDeadNode());
 
   // Make all of the outgoing links of N now be outgoing links of CurNodeH.
   //
@@ -985,7 +911,7 @@
     return;
   }
 
-  assert(!N->isDeadNode() && !isDeadNode());
+  assert(!N->NodeType.isDeadNode() && !NodeType.isDeadNode());
   assert(!hasNoReferrers() && "Should not try to fold a useless node!");
 
   if (N == this) {
@@ -1052,21 +978,8 @@
   }
 
   DSNode *DN = new DSNode(*SN, Dest, true /* Null out all links */);
-  DN->maskNodeTypes(BitsToKeep);
+  DN->NodeType.maskFlags(BitsToKeep);
   NH = DN;
-  //DOUT << "getClonedNH: " << SN << " becomes " << DN << "\n";
-#if 1
-#ifdef LLVA_KERNEL
-    //Again we have created a new DSNode, we need to fill in the
-    // pool desc map appropriately
-    hash_map<const DSNode *, MetaPoolHandle*> &pdm = Dest.getPoolDescriptorsMap();
-    if (pdm.count(SN) > 0) {
-      pdm[DN] = pdm[SN];
-    } else {
-      //do nothing 
-    }
-#endif    
-#endif
 
   // Next, recursively clone all outgoing links as necessary.  Note that
   // adding these links can cause the node to collapse itself at any time, and
@@ -1165,10 +1078,10 @@
       }
     }
 
-    assert(!DN->isDeadNode());
+    assert(!DN->NodeType.isDeadNode());
 
     // Merge the NodeType information.
-    DN->mergeNodeFlags(SN->getNodeFlags() & BitsToKeep);
+    DN->NodeType.mergeFlags(SN->NodeType.getFlags() & BitsToKeep);
 
     // Before we start merging outgoing links and updating the scalar map, make
     // sure it is known that this is the representative node for the src node.
@@ -1197,7 +1110,7 @@
     // We cannot handle this case without allocating a temporary node.  Fall
     // back on being simple.
     DSNode *NewDN = new DSNode(*SN, Dest, true /* Null out all links */);
-    NewDN->maskNodeTypes(BitsToKeep);
+    NewDN->NodeType.maskFlags(BitsToKeep);
 
     unsigned NHOffset = NH.getOffset();
     NH.mergeWith(DSNodeHandle(NewDN, SrcNH.getOffset()));
@@ -1225,54 +1138,6 @@
     }
   }
 
-  //  DOUT << "LLVA: mergeWith: " << SN << " becomes " << DN << "\n";
-
-#ifdef LLVA_KERNEL
-  //Here some merge is going on just like in DSNode::merge
-  //I think because of the inplace merging we don't update the pool desc maps
-  //This is modification from DSNode::MergeNodes
-  //Here DN and SN may belong to different graphs
- DN = NH.getNode(); 
-#if 0
-  DSGraph *destGraph =  DN->getParentGraph();
-  DSGraph *srcGraph =  SN->getParentGraph();
-#else
-  DSGraph *destGraph = NH.getNode()->getParentGraph();
-  DSGraph *srcGraph =  SN->getParentGraph();
-#endif
-  if (destGraph && srcGraph) {
-    //get the pooldescriptor map
-    hash_map<const DSNode *, MetaPoolHandle*> &destpdm = destGraph->getPoolDescriptorsMap();
-    hash_map<const DSNode *, MetaPoolHandle*> &srcpdm = srcGraph->getPoolDescriptorsMap();
-    if (destpdm.count(DN) == 0) {
-      if (srcpdm.count(SN) == 0) {
-        //do nothing  (common case)
-      } else {
-        if (srcpdm[SN]) {
-          DOUT << "DN becomes " << srcpdm[SN]->getName() << std::endl;
-          destpdm[DN] = srcpdm[SN];
-        }
-      }
-    } else {
-      if (srcpdm.count(SN) == 0) {
-        srcpdm[SN] = destpdm[DN];
-      } else {
-        if (destpdm[DN] != srcpdm[SN]) {
-          srcpdm[SN]->merge(destpdm[DN]);
-          /*
-          Value *dnv = destpdm[DN]->getMetaPoolValue();
-          Value *snv = srcpdm[SN]->getMetaPoolValue();
-          if (dnv != snv) {
-            DEBUG(std::cerr << "LLVA: Two Pools for one DSNode\n");
-            dnv->replaceAllUsesWith(snv);
-            destpdm[DN]->setMetaPoolValue(snv);
-          }
-          */
-        }
-      }
-    }
-  }
-#endif  
   // Next, recursively merge all outgoing links as necessary.  Note that
   // adding these links can cause the destination node to collapse itself at
   // any time, and the current node may be merged with arbitrary other nodes.
@@ -1356,53 +1221,6 @@
   NH = RC.getClonedNH(Src);
 }
 
-#ifdef LLVA_KERNEL
-// MetaPoolHandle Implementation
-  //The following should go in a cpp file later
-   MetaPoolHandle::MetaPoolHandle(MetaPool *mp, Instruction * Maker) {
-    Rep = mp;
-    Rep->insert(this);
-    Creator = Maker;
-  }
-  const std::string& MetaPoolHandle::getName() {
-    assert(Rep != 0 && "Null meta pool ??\n");
-    return Rep->getName();
-  }
-  Value *MetaPoolHandle::getMetaPoolValue() {
-    assert(Rep != 0 && "Null meta pool ??\n");
-    return Rep->getMetaPoolValue();
-  }
-  void MetaPoolHandle::merge(MetaPoolHandle *other) {
-    //after this operation other points to what this points to .
-    //first replace all uses 
-     Value *dest = getMetaPoolValue();
-     Value *curr = other->getMetaPoolValue();
-     if (dest != curr) {
-       std::cerr << "LLVA: Merging metapools: " << this->Creator->getParent()->getParent()->getName() << " : " << other->Creator->getParent()->getParent()->getName() << "\n"
-                 << "LLVA:   " << *(this->Creator) << "\n"
-                 << "LLVA:   " << *(other->Creator) << "\n";
-       curr->replaceAllUsesWith(dest);
-     }
-   
-     //merge the hash sets in to other
-     hash_set<MetaPoolHandle *> &otherHandleSet = other->getMetaPool()->getHandleSet();
-     hash_set<MetaPoolHandle *>::iterator ohsI = otherHandleSet.begin(), ohsE = otherHandleSet.end();
-     for (; ohsI != ohsE; ++ohsI) {
-     MetaPoolHandle *omph = *ohsI;
-     //now make sure that this omph points to what we point to
-     omph->setMetaPool(Rep);
-     Rep->insert(omph);
-     }
-
-     //now delete others MetaPool
-     //gd     delete other->getMetaPool(); 
-
-     //Assign our metapool to other 
-     other->setMetaPool(Rep);
-}
-
-#endif
-
 //===----------------------------------------------------------------------===//
 // DSGraph Implementation
 //===----------------------------------------------------------------------===//
@@ -1493,9 +1311,9 @@
   if (GlobalValue *GV = dyn_cast<GlobalValue>(Ptr)) {
     N->addGlobal(GV);
   } else if (isa<MallocInst>(Ptr)) {
-   N->setHeapMarker();
+   N->NodeType.setHeapNode();
   } else if (isa<AllocaInst>(Ptr)) {
-    N->setAllocaMarker();
+    N->NodeType.setAllocaNode();
   } else {
     assert(0 && "Illegal memory object input!");
   }
@@ -1525,7 +1343,7 @@
     assert(!I->isForwarding() &&
            "Forward nodes shouldn't be in node list!");
     DSNode *New = new DSNode(*I, this);
-    New->maskNodeTypes(~BitsToClear);
+    New->NodeType.maskFlags(~BitsToClear);
     OldNodeMap[I] = New;
   }
 
@@ -1688,7 +1506,7 @@
 
   // Base case: if we find a global, this doesn't reach the cloned graph
   // portion.
-  if (N->isGlobalNode()) {
+  if (N->NodeType.isGlobalNode()) {
     ThisNodeInfo.second = false;
     return ThisNodeInfo;
   }
@@ -1901,10 +1719,10 @@
 //
 static void markIncompleteNode(DSNode *N) {
   // Stop recursion if no node, or if node already marked...
-  if (N == 0 || N->isIncompleteNode()) return;
+  if (N == 0 || N->NodeType.isIncompleteNode()) return;
 
   // Actually mark the node
-  N->setIncompleteMarker();
+  N->NodeType.setIncompleteNode();
 
   // Recursively process children...
   for (DSNode::edge_iterator I = N->edge_begin(),E = N->edge_end(); I != E; ++I)
@@ -2014,7 +1832,7 @@
 
       // If the Callee is a useless edge, this must be an unreachable call site,
       // eliminate it.
-      if (Callee->getNumReferrers() == 1 && Callee->isCompleteNode() &&
+      if (Callee->getNumReferrers() == 1 && Callee->NodeType.isCompleteNode() &&
           Callee->isEmptyGlobals()) {  // No useful info?
         //errs() << "WARNING: Useless call site found.\n";
         Calls.erase(OldIt);
@@ -2026,7 +1844,7 @@
       // if the callee contains an external function, it will never be
       // resolvable, just merge the call sites.
       if (!LastCalleeNode.isNull() && LastCalleeNode.getNode() == Callee) {
-        LastCalleeContainsExternalFunction = Callee->isExternFunctionNode();
+        LastCalleeContainsExternalFunction = Callee->NodeType.isExternFunctionNode();
 
         std::list<DSCallSite>::iterator PrevIt = OldIt;
         --PrevIt;
@@ -2178,12 +1996,12 @@
 
     // Do not remove *any* global nodes in the globals graph.
     // This is a special case because such nodes may not have I, M, R flags set.
-    if (Node.isGlobalNode() && isGlobalsGraph) {
+    if (Node.NodeType.isGlobalNode() && isGlobalsGraph) {
       ++NI;
       continue;
     }
 
-    if (Node.isCompleteNode() && !Node.isModifiedNode() && !Node.isReadNode()) {
+    if (Node.NodeType.isCompleteNode() && !Node.NodeType.isModifiedNode() && !Node.NodeType.isReadNode()) {
       // This is a useless node if it has no mod/ref info (checked above),
       // outgoing edges (which it cannot, as it is not modified in this
       // context), and it has no incoming edges.  If it is a global node it may
@@ -2212,7 +2030,7 @@
     }
 
     if ((Node.getNodeFlags() == 0 && Node.hasNoReferrers())
-        || (isGlobalsGraph && Node.hasNoReferrers() && !Node.isGlobalNode())){
+        || (isGlobalsGraph && Node.hasNoReferrers() && !Node.NodeType.isGlobalNode())){
       // This node is dead!
       NI = Nodes.erase(NI);    // Erase & remove from node list.
       ++NumTrivialDNE;
@@ -2260,7 +2078,7 @@
 
   // If this is a global node, it will end up in the globals graph anyway, so we
   // don't need to worry about it.
-  if (IgnoreGlobals && N->isGlobalNode()) return false;
+  if (IgnoreGlobals && N->NodeType.isGlobalNode()) return false;
 
   // If we know that this node is alive, return so!
   if (Alive.count(N)) return true;
@@ -2332,7 +2150,7 @@
        I != E; ++I)
     if (isa<GlobalValue>(I->first)) {             // Keep track of global nodes
       assert(!I->second.isNull() && "Null global node?");
-      assert(I->second.getNode()->isGlobalNode() && "Should be a global node!");
+      assert(I->second.getNode()->NodeType.isGlobalNode() && "Should be a global node!");
       GlobalNodes.push_back(std::make_pair(I->first, I->second.getNode()));
 
       // Make sure that all globals are cloned over as roots.
@@ -2486,7 +2304,7 @@
     assert(!I->second.isNull() && "Null node in scalarmap!");
     AssertNodeInGraph(I->second.getNode());
     if (const GlobalValue *GV = dyn_cast<GlobalValue>(I->first)) {
-      assert(I->second.getNode()->isGlobalNode() &&
+      assert(I->second.getNode()->NodeType.isGlobalNode() &&
              "Global points to node, but node isn't global?");
       AssertNodeContainsGlobal(I->second.getNode(), GV);
     }

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/DataStructureAA.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructureAA.cpp Tue Sep  8 18:06:16 2009
@@ -146,7 +146,7 @@
     return AliasAnalysis::alias(V1, V1Size, V2, V2Size);
 
   // We can only make a judgment if one of the nodes is complete.
-  if (N1->isCompleteNode() || N2->isCompleteNode()) {
+  if (N1->NodeType.isCompleteNode() || N2->NodeType.isCompleteNode()) {
     if (N1 != N2)
       return NoAlias;   // Completely different nodes.
 
@@ -200,9 +200,9 @@
     // track of aggregate mod/ref info.
     bool NeverReads = true, NeverWrites = true;
     for (; Range.first != Range.second; ++Range.first) {
-      if (Range.first->second->isModifiedNode())
+      if (Range.first->second->NodeType.isModifiedNode())
         NeverWrites = false;
-      if (Range.first->second->isReadNode())
+      if (Range.first->second->NodeType.isReadNode())
         NeverReads = false;
       if (NeverReads == false && NeverWrites == false)
         return AliasAnalysis::getModRefInfo(CS, P, Size);
@@ -243,7 +243,7 @@
 
     // If we found a node and it's complete, it cannot be passed out to the
     // called function.
-    if (NI->second.getNode()->isCompleteNode())
+    if (NI->second.getNode()->NodeType.isCompleteNode())
       return NoModRef;
     return AliasAnalysis::getModRefInfo(CS, P, Size);
   }
@@ -273,9 +273,9 @@
         // Otherwise, if the node is only M or R, return this.  This can be
         // useful for globals that should be marked const but are not.
         DSNode *N = NI->second.getNode();
-        if (!N->isModifiedNode())
+        if (!N->NodeType.isModifiedNode())
           Result = (ModRefResult)(Result & ~Mod);
-        if (!N->isReadNode())
+        if (!N->NodeType.isReadNode())
           Result = (ModRefResult)(Result & ~Ref);
       }
     }

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructureOpt.cpp Tue Sep  8 18:06:16 2009
@@ -82,11 +82,11 @@
           I->replaceAllUsesWith(ConstantPointerNull::get(I->getType()));
           ++NumGlobalsIsolated;
         }
-      } else if (GNode && GNode->isCompleteNode()) {
+      } else if (GNode && GNode->NodeType.isCompleteNode()) {
 
         // If the node has not been read or written, and it is not externally
         // visible, kill any references to it so it can be DCE'd.
-        if (!GNode->isModifiedNode() && !GNode->isReadNode() &&I->hasInternalLinkage()){
+        if (!GNode->NodeType.isModifiedNode() && !GNode->NodeType.isReadNode() &&I->hasInternalLinkage()){
           if (!I->use_empty()) {
             I->replaceAllUsesWith(ConstantPointerNull::get(I->getType()));
             ++NumGlobalsIsolated;
@@ -96,7 +96,7 @@
         // We expect that there will almost always be a node for this global.
         // If there is, and the node doesn't have the M bit set, we can set the
         // 'constant' bit on the global.
-        if (!GNode->isModifiedNode() && !I->isConstant()) {
+        if (!GNode->NodeType.isModifiedNode() && !I->isConstant()) {
           I->setConstant(true);
           ++NumGlobalsConstanted;
           Changed = true;

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/DataStructureStats.cpp (original)
+++ poolalloc/trunk/lib/rDSA/DataStructureStats.cpp Tue Sep  8 18:06:16 2009
@@ -127,7 +127,7 @@
 
 bool DSGraphStats::isNodeForValueCollapsed(Value *V) {
   if (DSNode *N = getNodeForValue(V))
-    return N->isNodeCompletelyFolded() || N->isIncompleteNode();
+    return N->isNodeCompletelyFolded() || N->NodeType.isIncompleteNode();
   return false;
 }
 

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/Local.cpp (original)
+++ poolalloc/trunk/lib/rDSA/Local.cpp Tue Sep  8 18:06:16 2009
@@ -12,6 +12,8 @@
 //
 //===----------------------------------------------------------------------===//
 
+#define DEBUG_TYPE "dsa-local"
+
 #include "rdsa/DataStructure.h"
 #include "rdsa/DSGraph.h"
 #include "llvm/Module.h"
@@ -147,18 +149,10 @@
     // Visitor functions, used to handle each instruction type we encounter...
     friend class InstVisitor<GraphBuilderLocal>;
 
-    void visitMallocInst(MallocInst &MI)
-    { setDestTo(MI, createNode()->setHeapMarker()); }
-
-    void visitAllocaInst(AllocaInst &AI)
-    { setDestTo(AI, createNode()->setAllocaMarker()); }
-
-    void visitFreeInst(FreeInst &FI)
-    { if (DSNode *N = getValueDest(*FI.getOperand(0)).getNode())
-        N->setHeapMarker();
-    }
-
     //the simple ones
+    void visitMallocInst(MallocInst &MI);
+    void visitAllocaInst(AllocaInst &AI);
+    void visitFreeInst(FreeInst &FI);
     void visitPHINode(PHINode &PN);
     void visitSelectInst(SelectInst &SI);
     void visitLoadInst(LoadInst &LI);
@@ -185,42 +179,44 @@
     void visitCallSite(CallSite CS);
 
   public:
-    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) {
-        if (isa<PointerType>(I->getType())) {
-          DSNode * Node = getValueDest(*I).getNode();
-
-          if (!f.hasInternalLinkage())
-            Node->setExternalMarker();
-
-        }
-      }
+    GraphBuilderLocal(Function& f, DSNodeHandle& retnode, DSGraph* g, 
+                      DataStructures& DSi);
+  };
+}
 
-      visit(f);  // Single pass over the function
+GraphBuilderLocal::GraphBuilderLocal(Function& f, DSNodeHandle& retnode, DSGraph* g, DataStructures& DSi)
+  : GraphBuilderBase(g), DS(&DSi), RetNode(retnode) {
 
-      // 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);
-        
-        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));
-      }
+  // Create scalar nodes for all pointer arguments...
+  for (Function::arg_iterator I = f.arg_begin(), E = f.arg_end();
+       I != E; ++I) {
+    if (isa<PointerType>(I->getType())) {
+      DSNode * Node = getValueDest(*I).getNode();
       
-      g->markIncompleteNodes(DSGraph::MarkFormalArgs);
+      if (!f.hasInternalLinkage())
+        Node->NodeType.setEscapedNode();
       
-      // Remove any nodes made dead due to merging...
-      g->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
     }
-
-  };
-
+  }
+  
+  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);
+    
+    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));
+  }
+  
+  g->markIncompleteNodes(DSGraph::MarkFormalArgs);
+  
+  // Remove any nodes made dead due to merging...
+  g->removeDeadNodes(DSGraph::KeepUnreachableGlobals);
 }
 
 //===----------------------------------------------------------------------===//
@@ -266,15 +262,19 @@
       if (CE->isCast()) {
         if (isa<PointerType>(CE->getOperand(0)->getType()))
           NH = getValueDest(*CE->getOperand(0));
-        else
-          NH = createNode()->setUnknownMarker();
+        else {
+          NH = createNode();
+          NH.getNode()->NodeType.setUnknownNode();
+        }
       } else if (CE->getOpcode() == Instruction::GetElementPtr) {
         visitGetElementPtrInst(*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();
+        NH = createNode();
+        NH.getNode()->NodeType.setUnknownNode();
+        return NH;
       }
       if (NH.isNull()) {  // (getelementptr null, X) returns null
         eraseNodeForValue(V);
@@ -356,6 +356,22 @@
 //===----------------------------------------------------------------------===//
 // Specific instruction type handler implementations...
 //
+void GraphBuilderLocal::visitMallocInst(MallocInst &MI) {
+  DSNode* N = createNode();
+  N->NodeType.setHeapNode();
+  setDestTo(MI, N);
+}
+
+void GraphBuilderLocal::visitAllocaInst(AllocaInst &AI) {
+  DSNode* N = createNode();
+  N->NodeType.setAllocaNode();
+  setDestTo(AI, N);
+}
+
+void GraphBuilderLocal::visitFreeInst(FreeInst &FI) {
+  if (DSNode *N = getValueDest(*FI.getOperand(0)).getNode())
+    N->NodeType.setHeapNode();
+}
 
 // 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.
@@ -385,7 +401,7 @@
   if (Ptr.isNull()) return; // Load from null
 
   // Make that the node is read from...
-  Ptr.getNode()->setReadMarker();
+  Ptr.getNode()->NodeType.setReadNode();
 
   // Ensure a typerecord exists...
   Ptr.getNode()->mergeTypeInfo(LI.getType(), Ptr.getOffset(), false);
@@ -400,7 +416,7 @@
   if (Dest.isNull()) return;
 
   // Mark that the node is written to...
-  Dest.getNode()->setModifiedMarker();
+  Dest.getNode()->NodeType.setModifiedNode();
 
   // Ensure a type-record exists...
   Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset());
@@ -421,7 +437,8 @@
   if (Ptr.isNull()) return;
 
   // Make that the node is read and written
-  Ptr.getNode()->setReadMarker()->setModifiedMarker();
+  Ptr.getNode()->NodeType.setReadNode();
+  Ptr.getNode()->NodeType.setModifiedNode();
 
   // Ensure a type record exists.
   DSNode *PtrN = Ptr.getNode();
@@ -434,12 +451,15 @@
 void GraphBuilderLocal::visitIntToPtrInst(IntToPtrInst &I) {
 //  std::cerr << "cast in " << I.getParent()->getParent()->getName() << "\n";
 //  I.dump();
-  setDestTo(I, createNode()->setUnknownMarker()->setIntToPtrMarker()); 
+  DSNode* N = createNode();
+  N->NodeType.setUnknownNode();
+  N->NodeType.setIntToPtrNode();
+  setDestTo(I, N);
 }
 
 void GraphBuilderLocal::visitPtrToIntInst(PtrToIntInst& I) {
   if (DSNode* N = getValueDest(*I.getOperand(0)).getNode())
-    N->setPtrToIntMarker();
+    N->NodeType.setPtrToIntNode();
 }
 
 
@@ -536,7 +556,7 @@
     } else if (isa<PointerType>(*I)) {
       if (!isa<Constant>(I.getOperand()) ||
           !cast<Constant>(I.getOperand())->isNullValue())
-        Value.getNode()->setArrayMarker();
+        Value.getNode()->NodeType.setArrayNode();
     }
 
 
@@ -624,15 +644,21 @@
     // Mark the memory written by the vastart intrinsic as incomplete
     DSNodeHandle RetNH = getValueDest(**CS.arg_begin());
     if (DSNode *N = RetNH.getNode()) {
-      N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
-       ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
+      N->NodeType.setModifiedNode();
+      N->NodeType.setAllocaNode();
+      N->NodeType.setIncompleteNode();
+      N->NodeType.setUnknownNode();
+      N->foldNodeCompletely();
     }
 
     if (RetNH.hasLink(0)) {
       DSNodeHandle Link = RetNH.getLink(0);
       if (DSNode *N = Link.getNode()) {
-        N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
-         ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
+        N->NodeType.setModifiedNode();
+        N->NodeType.setAllocaNode();
+        N->NodeType.setIncompleteNode();
+        N->NodeType.setUnknownNode();
+        N->foldNodeCompletely();
       }
     } else {
       //
@@ -644,8 +670,11 @@
         Operand = CI->getOperand (0);
       RetNH = getValueDest(*Operand);
       if (DSNode *N = RetNH.getNode()) {
-        N->setModifiedMarker()->setAllocaMarker()->setIncompleteMarker()
-         ->setVAStartMarker()->setUnknownMarker()->foldNodeCompletely();
+        N->NodeType.setModifiedNode();
+        N->NodeType.setAllocaNode();
+        N->NodeType.setIncompleteNode();
+        N->NodeType.setUnknownNode();
+        N->foldNodeCompletely();
       }
     }
 
@@ -657,17 +686,21 @@
     return true;
   case Intrinsic::stacksave: {
     DSNode * Node = createNode();
-    Node->setAllocaMarker()->setIncompleteMarker()->setUnknownMarker();
+    Node->NodeType.setAllocaNode();
+    Node->NodeType.setIncompleteNode();
+    Node->NodeType.setUnknownNode();
     Node->foldNodeCompletely();
     setDestTo (*(CS.getInstruction()), Node);
     return true;
   }
-  case Intrinsic::stackrestore:
-    getValueDest(*CS.getInstruction()).getNode()->setAllocaMarker()
-                                                ->setIncompleteMarker()
-                                                ->setUnknownMarker()
-                                                ->foldNodeCompletely();
+  case Intrinsic::stackrestore: {
+    DSNode* Node = getValueDest(*CS.getInstruction()).getNode();
+    Node->NodeType.setAllocaNode();
+    Node->NodeType.setIncompleteNode();
+    Node->NodeType.setUnknownNode();
+    Node->foldNodeCompletely();
     return true;
+  }
   case Intrinsic::vaend:
   case Intrinsic::dbg_func_start:
   case Intrinsic::dbg_region_end:
@@ -681,19 +714,21 @@
     // modified.
     DSNodeHandle RetNH = getValueDest(**CS.arg_begin());
     RetNH.mergeWith(getValueDest(**(CS.arg_begin()+1)));
-    if (DSNode *N = RetNH.getNode())
-      N->setModifiedMarker()->setReadMarker();
+    if (DSNode *N = RetNH.getNode()) {
+      N->NodeType.setModifiedNode();
+      N->NodeType.setReadNode();
+    }
     return true;
   }
   case Intrinsic::memset:
     // Mark the memory modified.
     if (DSNode *N = getValueDest(**CS.arg_begin()).getNode())
-      N->setModifiedMarker();
+      N->NodeType.setModifiedNode();
     return true;
 
   case Intrinsic::eh_exception: {
     DSNode * Node = createNode();
-    Node->setIncompleteMarker();
+    Node->NodeType.setIncompleteNode();
     Node->foldNodeCompletely();
     setDestTo (*(CS.getInstruction()), Node);
     return true;
@@ -701,8 +736,8 @@
 
   case Intrinsic::atomic_cmp_swap: {
     DSNodeHandle Ptr = getValueDest(**CS.arg_begin());
-    Ptr.getNode()->setReadMarker();
-    Ptr.getNode()->setModifiedMarker();
+    Ptr.getNode()->NodeType.setReadNode();
+    Ptr.getNode()->NodeType.setModifiedNode();
     if (isa<PointerType>(F->getReturnType())) {
       setDestTo(*(CS.getInstruction()), getValueDest(**(CS.arg_begin() + 1)));
       getValueDest(**(CS.arg_begin() + 1))
@@ -722,8 +757,8 @@
   case Intrinsic::atomic_load_umin:
     {
       DSNodeHandle Ptr = getValueDest(**CS.arg_begin());
-      Ptr.getNode()->setReadMarker();
-      Ptr.getNode()->setModifiedMarker();
+      Ptr.getNode()->NodeType.setReadNode();
+      Ptr.getNode()->NodeType.setModifiedNode();
       if (isa<PointerType>(F->getReturnType()))
         setDestTo(*(CS.getInstruction()), getValueDest(**(CS.arg_begin() + 1)));
     }
@@ -743,7 +778,9 @@
   //
   case Intrinsic::returnaddress: {
     DSNode * Node = createNode();
-    Node->setAllocaMarker()->setIncompleteMarker()->setUnknownMarker();
+    Node->NodeType.setAllocaNode();
+    Node->NodeType.setIncompleteNode();
+    Node->NodeType.setUnknownNode();
     Node->foldNodeCompletely();
     setDestTo (*(CS.getInstruction()), Node);
     return true;
@@ -826,7 +863,7 @@
       CurNode.mergeWith(getValueDest(**I));
 
   if (DSNode *N = CurNode.getNode())
-    N->setUnknownMarker();
+    N->NodeType.setUnknownNode();
 }
 
 void GraphBuilderLocal::visitExtractValueInst(ExtractValueInst &I) {

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/Printer.cpp (original)
+++ poolalloc/trunk/lib/rDSA/Printer.cpp Tue Sep  8 18:06:16 2009
@@ -28,6 +28,7 @@
 #include <ostream>
 #include <fstream>
 #include <sstream>
+#include <string>
 using namespace llvm;
 
 // OnlyPrintMain - The DataStructure printer exposes this option to allow
@@ -64,26 +65,14 @@
     OS << "COLLAPSED";
   else {
     WriteTypeSymbolic(OS, N->getType(), M);
-    if (N->isArray())
+    if (N->NodeType.isArrayNode())
       OS << " array";
   }
-  if (unsigned NodeType = N->getNodeFlags()) {
+  if (N->NodeType.getFlags()) {
     OS << ": ";
-    if (NodeType & DSNode::AllocaNode     ) OS << "S";
-    if (NodeType & DSNode::HeapNode       ) OS << "H";
-    if (NodeType & DSNode::GlobalNode     ) OS << "G";
-    if (NodeType & DSNode::UnknownNode    ) OS << "U";
-    if (NodeType & DSNode::IncompleteNode ) OS << "I";
-    if (NodeType & DSNode::ModifiedNode   ) OS << "M";
-    if (NodeType & DSNode::ReadNode       ) OS << "R";
-    if (NodeType & DSNode::ExternalNode   ) OS << "E";
-    if (NodeType & DSNode::IntToPtrNode   ) OS << "P";
-    if (NodeType & DSNode::PtrToIntNode   ) OS << "2";
-
-#ifndef NDEBUG
-    if (NodeType & DSNode::DeadNode       ) OS << "<dead>";
-#endif
-    OS << "\n";
+    std::string str;
+    N->NodeType.appendString(str);
+    OS << str << "\n";
   }
 
   EquivalenceClasses<const GlobalValue*> *GlobalECs = 0;

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/StdLibPass.cpp (original)
+++ poolalloc/trunk/lib/rDSA/StdLibPass.cpp Tue Sep  8 18:06:16 2009
@@ -226,27 +226,27 @@
             if (CI->getOperand(0) == F) {
               DSGraph* Graph = getDSGraph(CI->getParent()->getParent());
               if (recFuncs[x].action.read[0])
-                Graph->getNodeForValue(CI).getNode()->setReadMarker();
+                Graph->getNodeForValue(CI).getNode()->NodeType.setReadNode();
               if (recFuncs[x].action.write[0])
-                Graph->getNodeForValue(CI).getNode()->setModifiedMarker();
+                Graph->getNodeForValue(CI).getNode()->NodeType.setModifiedNode();
               if (recFuncs[x].action.heap[0])
-                Graph->getNodeForValue(CI).getNode()->setHeapMarker();
+                Graph->getNodeForValue(CI).getNode()->NodeType.setHeapNode();
 
               for (unsigned y = 1; y < CI->getNumOperands(); ++y)
                 if (recFuncs[x].action.read[y])
                   if (isa<PointerType>(CI->getOperand(y)->getType()))
                     if (DSNode * Node=Graph->getNodeForValue(CI->getOperand(y)).getNode())
-                      Node->setReadMarker();
+                      Node->NodeType.setReadNode();
               for (unsigned y = 1; y < CI->getNumOperands(); ++y)
                 if (recFuncs[x].action.write[y])
                   if (isa<PointerType>(CI->getOperand(y)->getType()))
                     if (DSNode * Node=Graph->getNodeForValue(CI->getOperand(y)).getNode())
-                      Node->setModifiedMarker();
+                      Node->NodeType.setModifiedNode();
               for (unsigned y = 1; y < CI->getNumOperands(); ++y)
                 if (recFuncs[x].action.heap[y])
                   if (isa<PointerType>(CI->getOperand(y)->getType()))
                     if (DSNode * Node=Graph->getNodeForValue(CI->getOperand(y)).getNode())
-                      Node->setHeapMarker();
+                      Node->NodeType.setHeapNode();
 
               std::vector<DSNodeHandle> toMerge;
               if (recFuncs[x].action.mergeWithRet)

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp (original)
+++ poolalloc/trunk/lib/rDSA/SteensgaardAA.cpp Tue Sep  8 18:06:16 2009
@@ -96,8 +96,8 @@
     // this.  If one is complete and the other isn't, then they are obviously
     // different nodes.  If they are both complete, we can't say anything
     // useful.
-    if (I->second.getNode()->isCompleteNode() ||
-        J->second.getNode()->isCompleteNode()) {
+    if (I->second.getNode()->NodeType.isCompleteNode() ||
+        J->second.getNode()->NodeType.isCompleteNode()) {
       // If the two pointers point to different data structure graph nodes, they
       // cannot alias!
       if (V1H.getNode() != V2H.getNode())
@@ -135,7 +135,7 @@
 
   if (I != GSM.end() && !I->second.isNull()) {
     DSNode *N = I->second.getNode();
-    if (N->isCompleteNode()) {
+    if (N->NodeType.isCompleteNode()) {
       // If this is a direct call to an external function, and if the pointer
       // points to a complete node, the external function cannot modify or read
       // the value (we know it's not passed out of the program!).
@@ -145,9 +145,9 @@
 
       // Otherwise, if the node is complete, but it is only M or R, return this.
       // This can be useful for globals that should be marked const but are not.
-      if (!N->isModifiedNode())
+      if (!N->NodeType.isModifiedNode())
         Result = (ModRefResult)(Result & ~Mod);
-      if (!N->isReadNode())
+      if (!N->NodeType.isReadNode())
         Result = (ModRefResult)(Result & ~Ref);
     }
   }

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

==============================================================================
--- poolalloc/trunk/lib/rDSA/TopDownClosure.cpp (original)
+++ poolalloc/trunk/lib/rDSA/TopDownClosure.cpp Tue Sep  8 18:06:16 2009
@@ -80,7 +80,7 @@
   for (DSScalarMap::global_iterator I=GGSM.global_begin(), E=GGSM.global_end();
        I != E; ++I) {
     DSNode *N = GGSM.find(*I)->second.getNode();
-    if (N->isIncompleteNode())
+    if (N->NodeType.isIncompleteNode())
       markReachableFunctionsExternallyAccessible(N, Visited);
   }
 





More information about the llvm-commits mailing list