[llvm-commits] [poolalloc] r116388 - in /poolalloc/trunk/lib/DSA: DataStructure.cpp Local.cpp

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Oct 12 18:49:28 PDT 2010


Author: aggarwa4
Date: Tue Oct 12 20:49:28 2010
New Revision: 116388

URL: http://llvm.org/viewvc/llvm-project?rev=116388&view=rev
Log:
Fix the zero size error. The size for a VOID array is now
1 byte. 

Modified:
    poolalloc/trunk/lib/DSA/DataStructure.cpp
    poolalloc/trunk/lib/DSA/Local.cpp

Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=116388&r1=116387&r2=116388&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Tue Oct 12 20:49:28 2010
@@ -336,6 +336,10 @@
     assert (getSize() && "array node has size of zero!\n");
     Offset %= getSize();
   }
+  const TargetData &TD = getParentGraph()->getTargetData();
+  if (Offset >= getSize()) growSize(Offset+TD.getTypeAllocSize(NewTy));
+  if (Offset >= getSize() && NewTy->isVoidTy()) growSize(Offset + 1);
+
 
   if (Offset >= getSize()) growSize(Offset+1);
 
@@ -355,7 +359,10 @@
     if((*ni)->isIntegerTy()) {
       integerTy = true;
     }
+    const TargetData &TD = getParentGraph()->getTargetData();
+    if ((Offset + TD.getTypeAllocSize(*ni))>= getSize()) growSize(Offset+TD.getTypeAllocSize(*ni));
   }
+
   if(pointerTy && integerTy) {
     if(!hasLink(Offset)) {
       const DSNodeHandle &NH  = new DSNode(getParentGraph());

Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=116388&r1=116387&r2=116388&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Tue Oct 12 20:49:28 2010
@@ -567,13 +567,36 @@
       // increment the offset by the actual byte offset being accessed
       Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo);
       
-    } else if(isa<ArrayType>(*I)) {
-      // indexing into an array.
+    } else if(const ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
+       // indexing into an array.
+     const Type *CurTy = ATy->getElementType();
+
+      if(!isa<ArrayType>(CurTy) &&
+         Value.getNode()->getSize() <= 1) {
+          Value.getNode()->growSize(TD.getTypeAllocSize(CurTy));
+      }
+      if(CurTy->isVoidTy()) {
+        Value.getNode()->growSize(1);
+      }
+      if(isa<ArrayType>(CurTy) && Value.getNode()->getSize() <= 1){
+        const Type *ETy = (cast<ArrayType>(CurTy))->getElementType();
+        while(isa<ArrayType>(ETy)) {
+          ETy = (cast<ArrayType>(ETy))->getElementType();
+         }
+        Value.getNode()->growSize(TD.getTypeAllocSize(ETy));
+        if(ETy->isVoidTy()) {
+          Value.getNode()->growSize(1);
+        }
+     }
+// indexing into an array.
       Value.getNode()->setArrayMarker();
       
       // Find if the DSNode belongs to the array
       // If not fold.
-      if(Value.getOffset() || Offset != 0) {
+      if((Value.getOffset() || Offset != 0) 
+	 || (!isa<ArrayType>(CurTy)
+         && (Value.getNode()->getSize() != TD.getTypeAllocSize(CurTy)))) {
+
         Value.getNode()->foldNodeCompletely();
         Value.getNode();
         Offset = 0;





More information about the llvm-commits mailing list