[llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h DSGraphTraits.h DSNode.h

Chris Lattner lattner at cs.uiuc.edu
Thu Jun 19 16:15:02 PDT 2003


Changes in directory llvm/include/llvm/Analysis:

DSGraph.h updated: 1.48 -> 1.49
DSGraphTraits.h updated: 1.14 -> 1.15
DSNode.h updated: 1.24 -> 1.25

---
Log message:

Lots of changes to make the NodeType field private to DSNode.
Add new MultiObject flag


---
Diffs of the changes:

Index: llvm/include/llvm/Analysis/DSGraph.h
diff -u llvm/include/llvm/Analysis/DSGraph.h:1.48 llvm/include/llvm/Analysis/DSGraph.h:1.49
--- llvm/include/llvm/Analysis/DSGraph.h:1.48	Wed Jun 11 09:01:29 2003
+++ llvm/include/llvm/Analysis/DSGraph.h	Thu Jun 19 16:14:22 2003
@@ -137,9 +137,9 @@
   /// maskNodeTypes - Apply a mask to all of the node types in the graph.  This
   /// is useful for clearing out markers like Incomplete.
   ///
-  void maskNodeTypes(unsigned char Mask) {
+  void maskNodeTypes(unsigned Mask) {
     for (unsigned i = 0, e = Nodes.size(); i != e; ++i)
-      Nodes[i]->NodeType &= Mask;
+      Nodes[i]->maskNodeTypes(Mask);
   }
   void maskIncompleteMarkers() { maskNodeTypes(~DSNode::Incomplete); }
 


Index: llvm/include/llvm/Analysis/DSGraphTraits.h
diff -u llvm/include/llvm/Analysis/DSGraphTraits.h:1.14 llvm/include/llvm/Analysis/DSGraphTraits.h:1.15
--- llvm/include/llvm/Analysis/DSGraphTraits.h:1.14	Wed Jun 11 09:01:29 2003
+++ llvm/include/llvm/Analysis/DSGraphTraits.h	Thu Jun 19 16:14:22 2003
@@ -28,7 +28,7 @@
   DSNodeIterator(NodeTy *N, bool) : Node(N) {         // Create end iterator
     Offset = N->getNumLinks() << DS::PointerShift;
     if (Offset == 0 && Node->getForwardNode() &&
-        (Node->NodeType & DSNode::DEAD))        // Model Forward link
+        Node->isDeadNode())        // Model Forward link
       Offset += DS::PointerSize;
   }
 public:
@@ -47,7 +47,7 @@
   }
   
   pointer operator*() const {
-    if (Node->NodeType & DSNode::DEAD)
+    if (Node->isDeadNode())
       return Node->getForwardNode();
     else
       return Node->getLink(Offset).getNode();


Index: llvm/include/llvm/Analysis/DSNode.h
diff -u llvm/include/llvm/Analysis/DSNode.h:1.24 llvm/include/llvm/Analysis/DSNode.h:1.25
--- llvm/include/llvm/Analysis/DSNode.h:1.24	Wed Jun 11 09:01:29 2003
+++ llvm/include/llvm/Analysis/DSNode.h	Thu Jun 19 16:14:22 2003
@@ -69,24 +69,28 @@
     GlobalNode  = 1 << 2,   // This node was allocated by a global var decl
     UnknownNode = 1 << 3,   // This node points to unknown allocated memory 
     Incomplete  = 1 << 4,   // This node may not be complete
+
     Modified    = 1 << 5,   // This node is modified in this context
     Read        = 1 << 6,   // This node is read in this context
+
     Array       = 1 << 7,   // This node is treated like an array
-#if 1
-    DEAD        = 1 << 8,   // This node is dead and should not be pointed to
-#endif
+    MultiObject = 1 << 8,   // This node represents > 1 object (may alias)
+    //#ifndef NDEBUG
+    DEAD        = 1 << 9,   // This node is dead and should not be pointed to
+    //#endif
 
     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.  Scalar and Alloca markers go away
-  /// when function graphs are inlined.
+  /// with a value of 0 for their NodeType.
   ///
+private:
   unsigned short NodeType;
+public:
 
-  DSNode(unsigned NodeTy, const Type *T, DSGraph *G);
+  DSNode(const Type *T, DSGraph *G);
   DSNode(const DSNode &, DSGraph *G);
 
   ~DSNode() {
@@ -122,14 +126,6 @@
   /// return the number of nodes forwarding over the node!
   unsigned getNumReferrers() const { return NumReferrers; }
 
-  /// isModified - Return true if this node may be modified in this context
-  ///
-  bool isModified() const { return (NodeType & Modified) != 0; }
-
-  /// isRead - Return true if this node may be read in this context
-  ///
-  bool isRead() const { return (NodeType & Read) != 0; }
-
   DSGraph *getParentGraph() const { return ParentGraph; }
   void setParentGraph(DSGraph *G) { ParentGraph = G; }
 
@@ -234,7 +230,43 @@
   ///
   void addGlobal(GlobalValue *GV);
   const std::vector<GlobalValue*> &getGlobals() const { return Globals; }
-  std::vector<GlobalValue*> &getGlobals() { return Globals; }
+
+  /// maskNodeTypes - Apply a mask to the node types bitfield.
+  ///
+  void maskNodeTypes(unsigned Mask) {
+    NodeType &= Mask;
+  }
+
+  /// 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 & ~DEAD; }
+
+  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 isModified() const   { return NodeType & Modified; }
+  bool isRead() const       { return NodeType & Read; }
+
+  bool isIncomplete() const { return NodeType & Incomplete; }
+  bool isMultiObject() const { return NodeType & MultiObject; }
+  bool isDeadNode() const   { return NodeType & DEAD; }
+
+  DSNode *setAllocaNodeMarker()  { return setCompositionMarker(AllocaNode); }
+  DSNode *setHeapNodeMarker()    { return setCompositionMarker(HeapNode); }
+  DSNode *setGlobalNodeMarker()  { return setCompositionMarker(GlobalNode); }
+  DSNode *setUnknownNodeMarker() { return setCompositionMarker(UnknownNode); }
+
+  DSNode *setIncompleteMarker() { NodeType |= Incomplete; return this; }
+  DSNode *setModifiedMarker()   { NodeType |= Modified;   return this; }
+  DSNode *setReadMarker()       { NodeType |= Read;       return this; }
+
+  void makeNodeDead() {
+    Globals.clear();
+    assert(hasNoReferrers() && "Dead node shouldn't have refs!");
+    NodeType = DEAD;
+  }
 
   /// forwardNode - Mark this node as being obsolete, and all references to it
   /// should be forwarded to the specified node and offset.
@@ -265,6 +297,12 @@
 private:
   friend class DSNodeHandle;
 
+  DSNode *setCompositionMarker(unsigned Marker) {
+    if (NodeType & Composition) Marker |= MultiObject;
+    NodeType |= Marker;
+    return this;
+  }
+
   // static mergeNodes - Helper for mergeWith()
   static void MergeNodes(DSNodeHandle& CurNodeH, DSNodeHandle& NH);
 };
@@ -295,7 +333,6 @@
     }
   }
   assert(!N || ((N->NodeType & DSNode::DEAD) == 0));
-
   assert((!N || Offset < N->Size || (N->Size == 0 && Offset == 0) ||
           !N->ForwardNH.isNull()) && "Node handle offset out of range!");
 }





More information about the llvm-commits mailing list