[llvm-commits] [poolalloc] r72001 - in /poolalloc/trunk/lib: DSA/DataStructure.cpp DSA/Local.cpp PoolAllocate/Heuristic.cpp PoolAllocate/PASimple.cpp PoolAllocate/PointerCompress.cpp PoolAllocate/TransformFunctionBody.cpp

John Criswell criswell at uiuc.edu
Mon May 18 08:08:29 PDT 2009


Author: criswell
Date: Mon May 18 10:08:28 2009
New Revision: 72001

URL: http://llvm.org/viewvc/llvm-project?rev=72001&view=rev
Log:
Updated to new LLVM API for TargetData.
Patch contributed by Haohui Mai.

Modified:
    poolalloc/trunk/lib/DSA/DataStructure.cpp
    poolalloc/trunk/lib/DSA/Local.cpp
    poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
    poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
    poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
    poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp

Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStructure.cpp?rev=72001&r1=72000&r2=72001&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
+++ poolalloc/trunk/lib/DSA/DataStructure.cpp Mon May 18 10:08:28 2009
@@ -400,7 +400,7 @@
           const ArrayType *AT = cast<ArrayType>(SS.Ty);
           ++SS.Idx;
           if (SS.Idx != AT->getNumElements()) {
-            SS.Offset += unsigned(TD.getTypePaddedSize(AT->getElementType()));
+            SS.Offset += unsigned(TD.getTypeAllocSize(AT->getElementType()));
             return;
           }
           Stack.pop_back();  // At the end of the array
@@ -435,7 +435,7 @@
             assert(SS.Idx < AT->getNumElements());
             Stack.push_back(StackState(AT->getElementType(),
                                        SS.Offset+SS.Idx*
-                             unsigned(TD.getTypePaddedSize(AT->getElementType()))));
+                             unsigned(TD.getTypeAllocSize(AT->getElementType()))));
           }
         }
       }
@@ -492,7 +492,7 @@
           (Size == 0 && !Ty->isSized() && !isArray()) ||
           (Size == 1 && Ty == Type::VoidTy && isArray()) ||
           (Size == 0 && !Ty->isSized() && !isArray()) ||
-          (TD.getTypePaddedSize(Ty) == Size)) &&
+          (TD.getTypeAllocSize(Ty) == Size)) &&
          "Size member of DSNode doesn't match the type structure!");
   assert(NewTy != Type::VoidTy && "Cannot merge void type into DSNode!");
 
@@ -515,7 +515,7 @@
   }
 
   // Figure out how big the new type we're merging in is...
-  unsigned NewTySize = NewTy->isSized() ? (unsigned)TD.getTypePaddedSize(NewTy) : 0;
+  unsigned NewTySize = NewTy->isSized() ? (unsigned)TD.getTypeAllocSize(NewTy) : 0;
 
   // Otherwise check to see if we can fold this type into the current node.  If
   // we can't, we fold the node completely, if we can, we potentially update our
@@ -655,7 +655,7 @@
   unsigned O = 0;
   const Type *SubType = Ty;
   while (O < Offset) {
-    assert(Offset-O < TD.getTypePaddedSize(SubType) && "Offset out of range!");
+    assert(Offset-O < TD.getTypeAllocSize(SubType) && "Offset out of range!");
 
     switch (SubType->getTypeID()) {
     case Type::StructTyID: {
@@ -670,7 +670,7 @@
     }
     case Type::ArrayTyID: {
       SubType = cast<ArrayType>(SubType)->getElementType();
-      unsigned ElSize = (unsigned)TD.getTypePaddedSize(SubType);
+      unsigned ElSize = (unsigned)TD.getTypeAllocSize(SubType);
       unsigned Remainder = (Offset-O) % ElSize;
       O = Offset-Remainder;
       break;
@@ -692,7 +692,7 @@
       isa<FunctionType>(NewTy)) return false;
 
   unsigned SubTypeSize = SubType->isSized() ?
-       (unsigned)TD.getTypePaddedSize(SubType) : 0;
+       (unsigned)TD.getTypeAllocSize(SubType) : 0;
 
   // Ok, we are getting desperate now.  Check for physical subtyping, where we
   // just require each element in the node to be compatible.
@@ -720,12 +720,12 @@
       else
         NextPadSize = SubTypeSize;
       NextSubType = STy->getElementType(0);
-      NextSubTypeSize = (unsigned)TD.getTypePaddedSize(NextSubType);
+      NextSubTypeSize = (unsigned)TD.getTypeAllocSize(NextSubType);
       break;
     }
     case Type::ArrayTyID:
       NextSubType = cast<ArrayType>(SubType)->getElementType();
-      NextSubTypeSize = (unsigned)TD.getTypePaddedSize(NextSubType);
+      NextSubTypeSize = (unsigned)TD.getTypeAllocSize(NextSubType);
       NextPadSize = NextSubTypeSize;
       break;
     default: ;

Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=72001&r1=72000&r2=72001&view=diff

==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Mon May 18 10:08:28 2009
@@ -447,7 +447,7 @@
       if (ConstantInt *CS = dyn_cast<ConstantInt>(GEP.getOperand(i))) {
         Offset += 
           (CS->getType()->isSigned() ? CS->getSExtValue() : CS->getZExtValue())
-          * TD.getTypePaddedSize(CurTy);
+          * TD.getTypeAllocSize(CurTy);
       } else {
         // Variable index into a node.  We must merge all of the elements of the
         // sequential type here.
@@ -455,7 +455,7 @@
           cerr << "Pointer indexing not handled yet!\n";
         else {
           const ArrayType *ATy = cast<ArrayType>(STy);
-          unsigned ElSize = TD.getTypePaddedSize(CurTy);
+          unsigned ElSize = TD.getTypeAllocSize(CurTy);
           DSNode *N = Value.getNode();
           assert(N && "Value must have a node!");
           unsigned RawOffset = Offset+Value.getOffset();

Modified: poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp?rev=72001&r1=72000&r2=72001&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/Heuristic.cpp Mon May 18 10:08:28 2009
@@ -57,7 +57,7 @@
 unsigned Heuristic::getRecommendedSize(const DSNode *N) {
   unsigned PoolSize = 0;
   if (!N->isArray() && N->getType()->isSized()) {
-    PoolSize = N->getParentGraph()->getTargetData().getTypePaddedSize(N->getType());
+    PoolSize = N->getParentGraph()->getTargetData().getTypeAllocSize(N->getType());
   }
   if (PoolSize == 1) PoolSize = 0;
   return PoolSize;

Modified: poolalloc/trunk/lib/PoolAllocate/PASimple.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PASimple.cpp?rev=72001&r1=72000&r2=72001&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PASimple.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PASimple.cpp Mon May 18 10:08:28 2009
@@ -178,7 +178,7 @@
         if (MI->isArrayAllocation()) {
           Value * NumElements = MI->getArraySize();
           Value * ElementSize = ConstantInt::get (Type::Int32Ty,
-                                                  TD.getTypePaddedSize(MI->getAllocatedType()));
+                                                  TD.getTypeAllocSize(MI->getAllocatedType()));
           AllocSize = BinaryOperator::Create (Instruction::Mul,
                                               ElementSize,
                                               NumElements,
@@ -186,7 +186,7 @@
                                               MI);
         } else {
           AllocSize = ConstantInt::get (Type::Int32Ty,
-                                        TD.getTypePaddedSize(MI->getAllocatedType()));
+                                        TD.getTypeAllocSize(MI->getAllocatedType()));
         }
 
         Value* args[] = {TheGlobalPool, AllocSize};

Modified: poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp?rev=72001&r1=72000&r2=72001&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/PointerCompress.cpp Mon May 18 10:08:28 2009
@@ -226,7 +226,7 @@
   NewTy = ComputeCompressedType(Pool->getType(), 0, Nodes);
 
   // Get the compressed type size.
-  NewSize = NewTy->isSized() ? TD.getTypePaddedSize(NewTy) : 0;
+  NewSize = NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0;
 }
 
 
@@ -318,9 +318,9 @@
   const TargetData &TD = getNode()->getParentGraph()->getTargetData();
   std::cerr << "  From size: "
             << (getNode()->getType()->isSized() ? 
-                        TD.getTypePaddedSize(getNode()->getType()) : 0)
+                        TD.getTypeAllocSize(getNode()->getType()) : 0)
             << "  To size: "
-            << (NewTy->isSized() ? TD.getTypePaddedSize(NewTy) : 0) << "\n";
+            << (NewTy->isSized() ? TD.getTypeAllocSize(NewTy) : 0) << "\n";
   std::cerr << "Node: "; getNode()->dump();
   std::cerr << "New Type: " << *NewTy << "\n";
 }
@@ -733,7 +733,7 @@
           Idx = CastInst::CreateSExtOrBitCast(Idx, SCALARUINTTYPE, Idx->getName(), &GEPI);
 
         Constant *Scale = ConstantInt::get(SCALARUINTTYPE,
-                                            TD.getTypePaddedSize(ElTy));
+                                            TD.getTypeAllocSize(ElTy));
         Idx = BinaryOperator::CreateMul(Idx, Scale, "fieldidx", &GEPI);
         Val = BinaryOperator::CreateAdd(Val, Idx, GEPI.getName(), &GEPI);
       }

Modified: poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp?rev=72001&r1=72000&r2=72001&view=diff

==============================================================================
--- poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp (original)
+++ poolalloc/trunk/lib/PoolAllocate/TransformFunctionBody.cpp Mon May 18 10:08:28 2009
@@ -216,7 +216,7 @@
 
   TargetData &TD = PAInfo.getAnalysis<TargetData>();
   Value *AllocSize =
-    ConstantInt::get(Type::Int32Ty, TD.getTypePaddedSize(MI.getAllocatedType()));
+    ConstantInt::get(Type::Int32Ty, TD.getTypeAllocSize(MI.getAllocatedType()));
 
   if (MI.isArrayAllocation())
     AllocSize = BinaryOperator::Create(Instruction::Mul, AllocSize,
@@ -274,7 +274,7 @@
     if (PH == 0 || isa<ConstantPointerNull>(PH)) return;
     TargetData &TD = PAInfo.getAnalysis<TargetData>();
     Value *AllocSize =
-      ConstantInt::get(Type::Int32Ty, TD.getTypePaddedSize(MI.getAllocatedType()));
+      ConstantInt::get(Type::Int32Ty, TD.getTypeAllocSize(MI.getAllocatedType()));
     
     if (MI.isArrayAllocation())
       AllocSize = BinaryOperator::Create(Instruction::Mul, AllocSize,
@@ -335,7 +335,7 @@
 
 void FuncTransform::visitCallocCall(CallSite CS) {
   TargetData& TD = PAInfo.getAnalysis<TargetData>();
-  bool useLong = TD.getTypePaddedSize(PointerType::getUnqual(Type::Int8Ty)) != 4;
+  bool useLong = TD.getTypeAllocSize(PointerType::getUnqual(Type::Int8Ty)) != 4;
   
   Module *M = CS.getInstruction()->getParent()->getParent()->getParent();
   assert(CS.arg_end()-CS.arg_begin() == 2 && "calloc takes two arguments!");





More information about the llvm-commits mailing list