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

Arushi Aggarwal aggarwa4 at illinois.edu
Wed Apr 27 09:51:53 PDT 2011


Author: aggarwa4
Date: Wed Apr 27 11:51:53 2011
New Revision: 130308

URL: http://llvm.org/viewvc/llvm-project?rev=130308&view=rev
Log:
Refactor mergeTypeInfo, into 2 parts. One
that grows size of DSNode and one that does
the actual merging of types.

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

Modified: poolalloc/trunk/include/dsa/DSNode.h
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNode.h?rev=130308&r1=130307&r2=130308&view=diff
==============================================================================
--- poolalloc/trunk/include/dsa/DSNode.h (original)
+++ poolalloc/trunk/include/dsa/DSNode.h Wed Apr 27 11:51:53 2011
@@ -206,6 +206,8 @@
     assert(!isCollapsedNode() && "Growing a collapsed node");
     Size = NSize;
   }
+  
+  void growSizeForType(const Type *Ty, unsigned Offset);
 
   /// hasLink - Return true if this memory object has a link in slot LinkNo
   ///

Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=130308&r1=130307&r2=130308&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Wed Apr 27 11:51:53 2011
@@ -402,15 +402,11 @@
   }
 }
 
-/// mergeTypeInfo - This method merges the specified type into the current node
-/// at the specified offset.  This may update the current node's type record if
-/// this gives more information to the node, it may do nothing to the node if
-/// this information is already known, or it may merge the node completely (and
-/// return true) if the information is incompatible with what is already known.
-///
-/// This method returns true if the node is completely folded, otherwise false.
-///
-void DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset) {
+/// growSizeForType - This method increases the size of the node 
+/// to accomodate NewTy at the given offset. This is useful for
+/// updating the size of a DSNode, without actually inferring a 
+/// Type.
+void DSNode::growSizeForType(const Type *NewTy, unsigned Offset) {
 
   if (!NewTy || NewTy->isVoidTy()) return;
 
@@ -422,6 +418,20 @@
   if (Offset + TD.getTypeAllocSize(NewTy) >= getSize())
     growSize(Offset + TD.getTypeAllocSize(NewTy));
 
+}
+
+/// mergeTypeInfo - This method merges the specified type into the current node
+/// at the specified offset.  This may update the current node's type record if
+/// this gives more information to the node, it may do nothing to the node if
+/// this information is already known, or it may merge the node completely (and
+/// return true) if the information is incompatible with what is already known.
+///
+/// This method returns true if the node is completely folded, otherwise false.
+///
+void DSNode::mergeTypeInfo(const Type *NewTy, unsigned Offset) {
+
+  growSizeForType(NewTy, Offset);
+
   // Clang generates loads and stores of struct types.
   // %tmp12 = load %struct.demand* %retval, align 1 
 
@@ -429,6 +439,7 @@
   // individually(at the appropriate offset), instead of the 
   // struct type.
   if(NewTy->isStructTy()) {
+    const TargetData &TD = getParentGraph()->getTargetData();
     const StructType *STy = cast<StructType>(NewTy);
     const StructLayout *SL = TD.getStructLayout(cast<StructType>(STy));
     unsigned count = 0;
@@ -653,7 +664,6 @@
 /// point to this node).
 ///
 void DSNode::mergeWith(const DSNodeHandle &NH, unsigned Offset) {
-  //DOUT << "mergeWith: " << this << " becomes " << NH.getNode() << "\n";
   DSNode *N = NH.getNode();
   if (N == this && NH.getOffset() == Offset)
     return;  // Noop





More information about the llvm-commits mailing list