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

Chris Lattner lattner at cs.uiuc.edu
Wed Oct 30 23:45:01 PST 2002


Changes in directory llvm/include/llvm/Analysis:

DSGraph.h updated: 1.21 -> 1.22

---
Log message:

This fixes all kinds of problems with array handling.  There are still bugs to
be fixed, but we are getting much closer now.

    * Make DSNode::TypeRec a full fledged DSTypeRec type.
    * Add methods used to update and access the typerecords elements
    * Add methods to query if and to cause a node to be completely folded
    * DSGraph construction doesn't use the allocation type for anything at all,
      now nodes get their type information based on how they are used. 
    * Fixed a bug with global value handling introduced in the last checkin
    * GEP support is now much better, arrays are handled correctly.  The array
      flag is now updated in type records.  There are still cases that are not
      handled yet (we do not detect pessimizations), but getting much closer.



---
Diffs of the changes:

Index: llvm/include/llvm/Analysis/DSGraph.h
diff -u llvm/include/llvm/Analysis/DSGraph.h:1.21 llvm/include/llvm/Analysis/DSGraph.h:1.22
--- llvm/include/llvm/Analysis/DSGraph.h:1.21	Sun Oct 27 13:04:59 2002
+++ llvm/include/llvm/Analysis/DSGraph.h	Wed Oct 30 23:44:44 2002
@@ -83,6 +83,30 @@
 
 
 //===----------------------------------------------------------------------===//
+/// DSTypeRec - This structure is used to represent a single type that is held
+/// in a DSNode.
+///
+struct DSTypeRec {
+  const Type *Ty;                 // The type itself...
+  unsigned Offset;                // The offset in the node
+  bool isArray;                   // Have we accessed an array of elements?
+  
+  DSTypeRec() : Ty(0), Offset(0), isArray(false) {}
+  DSTypeRec(const Type *T, unsigned O) : Ty(T), Offset(O), isArray(false) {}
+  
+  bool operator<(const DSTypeRec &TR) const {
+    // Sort first by offset!
+    return Offset < TR.Offset || (Offset == TR.Offset && Ty < TR.Ty);
+  }
+  bool operator==(const DSTypeRec &TR) const {
+    return Ty == TR.Ty && Offset == TR.Offset;
+  }
+  bool operator!=(const DSTypeRec &TR) const { return !operator==(TR); }
+};
+
+
+
+//===----------------------------------------------------------------------===//
 /// DSNode - Data structure node class
 ///
 /// This class represents an untyped memory object of Size bytes.  It keeps
@@ -121,31 +145,11 @@
   ///
   std::vector<DSNodeHandle*> Referrers;
 
-  /// TypeRec - This structure is used to represent a single type that is held
-  /// in a DSNode.
-  struct TypeRec {
-    const Type *Ty;                 // The type itself...
-    unsigned Offset;                // The offset in the node
-    bool isArray;                   // Have we accessed an array of elements?
-
-    TypeRec() : Ty(0), Offset(0), isArray(false) {}
-    TypeRec(const Type *T, unsigned O) : Ty(T), Offset(O), isArray(false) {}
-
-    bool operator<(const TypeRec &TR) const {
-      // Sort first by offset!
-      return Offset < TR.Offset || (Offset == TR.Offset && Ty < TR.Ty);
-    }
-    bool operator==(const TypeRec &TR) const {
-      return Ty == TR.Ty && Offset == TR.Offset;
-    }
-    bool operator!=(const TypeRec &TR) const { return !operator==(TR); }
-  };
-
   /// TypeEntries - As part of the merging process of this algorithm, nodes of
   /// different types can be represented by this single DSNode.  This vector is
   /// kept sorted.
   ///
-  std::vector<TypeRec> TypeEntries;
+  std::vector<DSTypeRec> TypeEntries;
 
   /// Globals - The list of global values that are merged into this node.
   ///
@@ -195,7 +199,7 @@
   unsigned getSize() const { return MergeMap.size(); }
 
   // getTypeEntries - Return the possible types and their offsets in this object
-  const std::vector<TypeRec> &getTypeEntries() const { return TypeEntries; }
+  const std::vector<DSTypeRec> &getTypeEntries() const { return TypeEntries; }
 
   /// getReferrers - Return a list of the pointers to this node...
   ///
@@ -229,11 +233,35 @@
     return 0;
   }
 
+  /// getMergeMapLabel - Return the merge map entry specified, to allow printing
+  /// out of DSNodes nicely for DOT graphs.
+  ///
   int getMergeMapLabel(unsigned i) const {
     assert(i < MergeMap.size() && "MergeMap index out of range!");
     return MergeMap[i];
   }
 
+  /// getTypeRec - This method returns the specified type record if it exists.
+  /// If it does not yet exist, the method checks to see whether or not the
+  /// request would result in an untrackable state.  If adding it would cause
+  /// untrackable state, we foldNodeCompletely the node and return the void
+  /// record, otherwise we add an new TypeEntry and return it.
+  ///
+  DSTypeRec &getTypeRec(const Type *Ty, unsigned Offset);
+
+  /// foldNodeCompletely - If we determine that this node has some funny
+  /// behavior happening to it that we cannot represent, we fold it down to a
+  /// single, completely pessimistic, node.  This node is represented as a
+  /// single byte with a single TypeEntry of "void".
+  ///
+  void foldNodeCompletely();
+
+  /// isNodeCompletelyFolded - Return true if this node has been completely
+  /// folded down to something that can never be expanded, effectively losing
+  /// all of the field sensitivity that may be present in the node.
+  ///
+  bool isNodeCompletelyFolded() const;
+
   /// setLink - Set the link at the specified offset to the specified
   /// NodeHandle, replacing what was there.  It is uncommon to use this method,
   /// instead one of the higher level methods should be used, below.
@@ -305,6 +333,16 @@
   /// rewriting the map entries.
   ///
   void mergeMappedValues(signed char V1, signed char V2);
+
+  /// growNode - Attempt to grow the node to the specified size.  This may do
+  /// one of three things:
+  ///   1. Grow the node, return false
+  ///   2. Refuse to grow the node, but maintain a trackable situation, return
+  ///      false.
+  ///   3. Be unable to track if node was that size, so collapse the node and
+  ///      return true.
+  ///
+  bool growNode(unsigned RequestedSize);
 };
 
 





More information about the llvm-commits mailing list