[llvm-commits] CVS: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp

Andrew Lenharth alenhar2 at cs.uiuc.edu
Mon Feb 20 14:03:27 PST 2006



Changes in directory llvm-poolalloc/lib/PoolAllocate:

PointerCompress.cpp updated: 1.65 -> 1.66
---
Log message:

Fix cae of malloc of array of objects instead of just malloc of objects

Fixes Shootout/lists (see regression directory for test case)



---
Diffs of the changes:  (+13 -0)

 PointerCompress.cpp |   13 +++++++++++++
 1 files changed, 13 insertions(+)


Index: llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp
diff -u llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.65 llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.66
--- llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp:1.65	Wed Jan 25 16:07:36 2006
+++ llvm-poolalloc/lib/PoolAllocate/PointerCompress.cpp	Mon Feb 20 16:03:14 2006
@@ -654,6 +654,19 @@
   // pointed to the start of a node!
   const Type *NTy = PointerType::get(PI->getNewType());
 
+  //Check if we have a pointer to an array of Original Types this happens if
+  //you do a malloc of [n x OrigTy] for a pool of Type OrigTy
+  if(isa<PointerType>(GEPI.getOperand(0)->getType())) {
+    const Type* PT =
+      cast<PointerType>(GEPI.getOperand(0)->getType())->getElementType();
+    if(isa<ArrayType>(PT)) {
+      if (cast<ArrayType>(PT)->getElementType() == PI->getNode()->getType())
+        NTy = PointerType::get(ArrayType::get(PI->getNewType(),
+                                              cast<ArrayType>(PT)->getNumElements()));
+    }
+  }
+
+
   gep_type_iterator GTI = gep_type_begin(GEPI), E = gep_type_end(GEPI);
   for (unsigned i = 1, e = GEPI.getNumOperands(); i != e; ++i, ++GTI) {
     Value *Idx = GEPI.getOperand(i);






More information about the llvm-commits mailing list