Rename getABITypeSize to getTypePaddedSize, as
suggested by Chris.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62099 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 0fb3359..1da33e6 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -511,7 +511,7 @@
       return 0; // It's not worth it.
     NewGlobals.reserve(NumElements);
     
-    uint64_t EltSize = TD.getABITypeSize(STy->getElementType());
+    uint64_t EltSize = TD.getTypePaddedSize(STy->getElementType());
     unsigned EltAlign = TD.getABITypeAlignment(STy->getElementType());
     for (unsigned i = 0, e = NumElements; i != e; ++i) {
       Constant *In = getAggregateConstantElement(Init,
@@ -1445,7 +1445,7 @@
     // (2048 bytes currently), as we don't want to introduce a 16M global or
     // something.
     if (NElements->getZExtValue()*
-        TD.getABITypeSize(MI->getAllocatedType()) < 2048) {
+        TD.getTypePaddedSize(MI->getAllocatedType()) < 2048) {
       GVI = OptimizeGlobalAddressOfMalloc(GV, MI);
       return true;
     }
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp
index 125b076..be7ed9c 100644
--- a/lib/Transforms/Scalar/CodeGenPrepare.cpp
+++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp
@@ -817,7 +817,7 @@
           cast<ConstantInt>(AddrInst->getOperand(i))->getZExtValue();
         ConstantOffset += SL->getElementOffset(Idx);
       } else {
-        uint64_t TypeSize = TD->getABITypeSize(GTI.getIndexedType());
+        uint64_t TypeSize = TD->getTypePaddedSize(GTI.getIndexedType());
         if (ConstantInt *CI = dyn_cast<ConstantInt>(AddrInst->getOperand(i))) {
           ConstantOffset += CI->getSExtValue()*TypeSize;
         } else if (TypeSize) {  // Scales of zero don't do anything.
diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 8b40da6..2d38e76 100644
--- a/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -305,11 +305,11 @@
         if (AllocaInst* A = dyn_cast<AllocaInst>(*I)) {
           if (ConstantInt* C = dyn_cast<ConstantInt>(A->getArraySize()))
             pointerSize = C->getZExtValue() *
-                          TD.getABITypeSize(A->getAllocatedType());
+                          TD.getTypePaddedSize(A->getAllocatedType());
         } else {
           const PointerType* PT = cast<PointerType>(
                                                  cast<Argument>(*I)->getType());
-          pointerSize = TD.getABITypeSize(PT->getElementType());
+          pointerSize = TD.getTypePaddedSize(PT->getElementType());
         }
 
         // See if the call site touches it
@@ -382,10 +382,10 @@
     if (AllocaInst* A = dyn_cast<AllocaInst>(*I)) {
       if (ConstantInt* C = dyn_cast<ConstantInt>(A->getArraySize()))
         pointerSize = C->getZExtValue() *
-                      TD.getABITypeSize(A->getAllocatedType());
+                      TD.getTypePaddedSize(A->getAllocatedType());
     } else {
       const PointerType* PT = cast<PointerType>(cast<Argument>(*I)->getType());
-      pointerSize = TD.getABITypeSize(PT->getElementType());
+      pointerSize = TD.getTypePaddedSize(PT->getElementType());
     }
 
     // See if this pointer could alias it
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 4921531..ee3596b 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -5142,7 +5142,7 @@
   for (User::op_iterator i = GEP->op_begin() + 1, e = GEP->op_end(); i != e;
        ++i, ++GTI) {
     Value *Op = *i;
-    uint64_t Size = TD.getABITypeSize(GTI.getIndexedType()) & PtrSizeMask;
+    uint64_t Size = TD.getTypePaddedSize(GTI.getIndexedType()) & PtrSizeMask;
     if (ConstantInt *OpC = dyn_cast<ConstantInt>(Op)) {
       if (OpC->isZero()) continue;
       
@@ -5233,7 +5233,7 @@
       if (const StructType *STy = dyn_cast<StructType>(*GTI)) {
         Offset += TD.getStructLayout(STy)->getElementOffset(CI->getZExtValue());
       } else {
-        uint64_t Size = TD.getABITypeSize(GTI.getIndexedType());
+        uint64_t Size = TD.getTypePaddedSize(GTI.getIndexedType());
         Offset += Size*CI->getSExtValue();
       }
     } else {
@@ -5249,7 +5249,7 @@
   Value *VariableIdx = GEP->getOperand(i);
   // Determine the scale factor of the variable element.  For example, this is
   // 4 if the variable index is into an array of i32.
-  uint64_t VariableScale = TD.getABITypeSize(GTI.getIndexedType());
+  uint64_t VariableScale = TD.getTypePaddedSize(GTI.getIndexedType());
   
   // Verify that there are no other variable indices.  If so, emit the hard way.
   for (++i, ++GTI; i != e; ++i, ++GTI) {
@@ -5263,7 +5263,7 @@
     if (const StructType *STy = dyn_cast<StructType>(*GTI)) {
       Offset += TD.getStructLayout(STy)->getElementOffset(CI->getZExtValue());
     } else {
-      uint64_t Size = TD.getABITypeSize(GTI.getIndexedType());
+      uint64_t Size = TD.getTypePaddedSize(GTI.getIndexedType());
       Offset += Size*CI->getSExtValue();
     }
   }
@@ -7419,8 +7419,8 @@
   // same, we open the door to infinite loops of various kinds.
   if (!AI.hasOneUse() && CastElTyAlign == AllocElTyAlign) return 0;
 
-  uint64_t AllocElTySize = TD->getABITypeSize(AllocElTy);
-  uint64_t CastElTySize = TD->getABITypeSize(CastElTy);
+  uint64_t AllocElTySize = TD->getTypePaddedSize(AllocElTy);
+  uint64_t CastElTySize = TD->getTypePaddedSize(CastElTy);
   if (CastElTySize == 0 || AllocElTySize == 0) return 0;
 
   // See if we can satisfy the modulus by pulling a scale out of the array
@@ -7708,7 +7708,7 @@
   // is something like [0 x {int, int}]
   const Type *IntPtrTy = TD->getIntPtrType();
   int64_t FirstIdx = 0;
-  if (int64_t TySize = TD->getABITypeSize(Ty)) {
+  if (int64_t TySize = TD->getTypePaddedSize(Ty)) {
     FirstIdx = Offset/TySize;
     Offset -= FirstIdx*TySize;
     
@@ -7740,7 +7740,7 @@
       Offset -= SL->getElementOffset(Elt);
       Ty = STy->getElementType(Elt);
     } else if (const ArrayType *AT = dyn_cast<ArrayType>(Ty)) {
-      uint64_t EltSize = TD->getABITypeSize(AT->getElementType());
+      uint64_t EltSize = TD->getTypePaddedSize(AT->getElementType());
       assert(EltSize && "Cannot index into a zero-sized array");
       NewIndices.push_back(ConstantInt::get(IntPtrTy,Offset/EltSize));
       Offset %= EltSize;
@@ -8407,7 +8407,7 @@
     // is a single-index GEP.
     if (X->getType() == CI.getType()) {
       // Get the size of the pointee type.
-      uint64_t Size = TD->getABITypeSize(DestPointee);
+      uint64_t Size = TD->getTypePaddedSize(DestPointee);
 
       // Convert the constant to intptr type.
       APInt Offset = Cst->getValue();
@@ -8427,7 +8427,7 @@
     // "inttoptr+GEP" instead of "add+intptr".
     
     // Get the size of the pointee type.
-    uint64_t Size = TD->getABITypeSize(DestPointee);
+    uint64_t Size = TD->getTypePaddedSize(DestPointee);
     
     // Convert the constant to intptr type.
     APInt Offset = Cst->getValue();
@@ -9492,7 +9492,7 @@
   const Type* DstTy = cast<PointerType>(CI->getType())->getElementType();
   if (!SrcTy->isSized() || !DstTy->isSized())
     return false;
-  if (TD->getABITypeSize(SrcTy) != TD->getABITypeSize(DstTy))
+  if (TD->getTypePaddedSize(SrcTy) != TD->getTypePaddedSize(DstTy))
     return false;
   return true;
 }
@@ -10608,8 +10608,8 @@
       const Type *SrcElTy = cast<PointerType>(X->getType())->getElementType();
       const Type *ResElTy=cast<PointerType>(PtrOp->getType())->getElementType();
       if (isa<ArrayType>(SrcElTy) &&
-          TD->getABITypeSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
-          TD->getABITypeSize(ResElTy)) {
+          TD->getTypePaddedSize(cast<ArrayType>(SrcElTy)->getElementType()) ==
+          TD->getTypePaddedSize(ResElTy)) {
         Value *Idx[2];
         Idx[0] = Constant::getNullValue(Type::Int32Ty);
         Idx[1] = GEP.getOperand(1);
@@ -10626,7 +10626,7 @@
       
       if (isa<ArrayType>(SrcElTy) && ResElTy == Type::Int8Ty) {
         uint64_t ArrayEltSize =
-            TD->getABITypeSize(cast<ArrayType>(SrcElTy)->getElementType());
+            TD->getTypePaddedSize(cast<ArrayType>(SrcElTy)->getElementType());
         
         // Check to see if "tmp" is a scale by a multiple of ArrayEltSize.  We
         // allow either a mul, shift, or constant here.
@@ -10779,7 +10779,7 @@
   // Note that we only do this for alloca's, because malloc should allocate and
   // return a unique pointer, even for a zero byte allocation.
   if (isa<AllocaInst>(AI) && AI.getAllocatedType()->isSized() &&
-      TD->getABITypeSize(AI.getAllocatedType()) == 0)
+      TD->getTypePaddedSize(AI.getAllocatedType()) == 0)
     return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType()));
 
   return 0;
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index fc61b9e..c8f2ce2 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -330,7 +330,7 @@
       Value *OpVal = getCastedVersionOf(opcode, *i);
       SCEVHandle Idx = SE->getSCEV(OpVal);
 
-      uint64_t TypeSize = TD->getABITypeSize(GTI.getIndexedType());
+      uint64_t TypeSize = TD->getTypePaddedSize(GTI.getIndexedType());
       if (TypeSize != 1)
         Idx = SE->getMulExpr(Idx,
                             SE->getConstant(ConstantInt::get(UIntPtrTy,
diff --git a/lib/Transforms/Scalar/MemCpyOptimizer.cpp b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
index 5e9c5ea..be9db96 100644
--- a/lib/Transforms/Scalar/MemCpyOptimizer.cpp
+++ b/lib/Transforms/Scalar/MemCpyOptimizer.cpp
@@ -104,7 +104,7 @@
     
     // Otherwise, we have a sequential type like an array or vector.  Multiply
     // the index by the ElementSize.
-    uint64_t Size = TD.getABITypeSize(GTI.getIndexedType());
+    uint64_t Size = TD.getTypePaddedSize(GTI.getIndexedType());
     Offset += Size*OpC->getSExtValue();
   }
 
@@ -511,7 +511,7 @@
   if (!srcArraySize)
     return false;
 
-  uint64_t srcSize = TD.getABITypeSize(srcAlloca->getAllocatedType()) *
+  uint64_t srcSize = TD.getTypePaddedSize(srcAlloca->getAllocatedType()) *
     srcArraySize->getZExtValue();
 
   if (cpyLength->getZExtValue() < srcSize)
@@ -526,7 +526,7 @@
     if (!destArraySize)
       return false;
 
-    uint64_t destSize = TD.getABITypeSize(A->getAllocatedType()) *
+    uint64_t destSize = TD.getTypePaddedSize(A->getAllocatedType()) *
       destArraySize->getZExtValue();
 
     if (destSize < srcSize)
@@ -538,7 +538,7 @@
       return false;
 
     const Type* StructTy = cast<PointerType>(A->getType())->getElementType();
-    uint64_t destSize = TD.getABITypeSize(StructTy);
+    uint64_t destSize = TD.getTypePaddedSize(StructTy);
 
     if (destSize < srcSize)
       return false;
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index d7b8b58..18716b7 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -243,7 +243,7 @@
          isa<ArrayType>(AI->getAllocatedType())) &&
         AI->getAllocatedType()->isSized() &&
         // Do not promote any struct whose size is larger than "128" bytes.
-        TD->getABITypeSize(AI->getAllocatedType()) < SRThreshold &&
+        TD->getTypePaddedSize(AI->getAllocatedType()) < SRThreshold &&
         // Do not promote any struct into more than "32" separate vars.
         getNumSAElements(AI->getAllocatedType()) < SRThreshold/4) {
       // Check that all of the users of the allocation are capable of being
@@ -562,7 +562,7 @@
   
   // If not the whole aggregate, give up.
   if (Length->getZExtValue() !=
-      TD->getABITypeSize(AI->getType()->getElementType()))
+      TD->getTypePaddedSize(AI->getType()->getElementType()))
     return MarkUnsafe(Info);
   
   // We only know about memcpy/memset/memmove.
@@ -595,8 +595,8 @@
       // cast a {i32,i32}* to i64* and store through it.  This is similar to the
       // memcpy case and occurs in various "byval" cases and emulated memcpys.
       if (isa<IntegerType>(SI->getOperand(0)->getType()) &&
-          TD->getABITypeSize(SI->getOperand(0)->getType()) == 
-          TD->getABITypeSize(AI->getType()->getElementType())) {
+          TD->getTypePaddedSize(SI->getOperand(0)->getType()) ==
+          TD->getTypePaddedSize(AI->getType()->getElementType())) {
         Info.isMemCpyDst = true;
         continue;
       }
@@ -607,8 +607,8 @@
       // cast a {i32,i32}* to i64* and load through it.  This is similar to the
       // memcpy case and occurs in various "byval" cases and emulated memcpys.
       if (isa<IntegerType>(LI->getType()) &&
-          TD->getABITypeSize(LI->getType()) == 
-          TD->getABITypeSize(AI->getType()->getElementType())) {
+          TD->getTypePaddedSize(LI->getType()) ==
+          TD->getTypePaddedSize(AI->getType()->getElementType())) {
         Info.isMemCpySrc = true;
         continue;
       }
@@ -789,7 +789,7 @@
       OtherElt = new BitCastInst(OtherElt, BytePtrTy,OtherElt->getNameStr(),
                                  MI);
     
-    unsigned EltSize = TD->getABITypeSize(EltTy);
+    unsigned EltSize = TD->getTypePaddedSize(EltTy);
     
     // Finally, insert the meminst for this element.
     if (isa<MemCpyInst>(MI) || isa<MemMoveInst>(MI)) {
@@ -823,13 +823,13 @@
   // and store the element value to the individual alloca.
   Value *SrcVal = SI->getOperand(0);
   const Type *AllocaEltTy = AI->getType()->getElementType();
-  uint64_t AllocaSizeBits = TD->getABITypeSizeInBits(AllocaEltTy);
+  uint64_t AllocaSizeBits = TD->getTypePaddedSizeInBits(AllocaEltTy);
   
   // If this isn't a store of an integer to the whole alloca, it may be a store
   // to the first element.  Just ignore the store in this case and normal SROA
   // will handle it.
   if (!isa<IntegerType>(SrcVal->getType()) ||
-      TD->getABITypeSizeInBits(SrcVal->getType()) != AllocaSizeBits)
+      TD->getTypePaddedSizeInBits(SrcVal->getType()) != AllocaSizeBits)
     return;
 
   DOUT << "PROMOTING STORE TO WHOLE ALLOCA: " << *AI << *SI;
@@ -845,7 +845,7 @@
       uint64_t Shift = Layout->getElementOffsetInBits(i);
       
       if (TD->isBigEndian())
-        Shift = AllocaSizeBits-Shift-TD->getABITypeSizeInBits(FieldTy);
+        Shift = AllocaSizeBits-Shift-TD->getTypePaddedSizeInBits(FieldTy);
       
       Value *EltVal = SrcVal;
       if (Shift) {
@@ -880,7 +880,7 @@
   } else {
     const ArrayType *ATy = cast<ArrayType>(AllocaEltTy);
     const Type *ArrayEltTy = ATy->getElementType();
-    uint64_t ElementOffset = TD->getABITypeSizeInBits(ArrayEltTy);
+    uint64_t ElementOffset = TD->getTypePaddedSizeInBits(ArrayEltTy);
     uint64_t ElementSizeBits = TD->getTypeSizeInBits(ArrayEltTy);
 
     uint64_t Shift;
@@ -935,13 +935,13 @@
   // Extract each element out of the NewElts according to its structure offset
   // and form the result value.
   const Type *AllocaEltTy = AI->getType()->getElementType();
-  uint64_t AllocaSizeBits = TD->getABITypeSizeInBits(AllocaEltTy);
+  uint64_t AllocaSizeBits = TD->getTypePaddedSizeInBits(AllocaEltTy);
   
   // If this isn't a load of the whole alloca to an integer, it may be a load
   // of the first element.  Just ignore the load in this case and normal SROA
   // will handle it.
   if (!isa<IntegerType>(LI->getType()) ||
-      TD->getABITypeSizeInBits(LI->getType()) != AllocaSizeBits)
+      TD->getTypePaddedSizeInBits(LI->getType()) != AllocaSizeBits)
     return;
   
   DOUT << "PROMOTING LOAD OF WHOLE ALLOCA: " << *AI << *LI;
@@ -954,7 +954,7 @@
     Layout = TD->getStructLayout(EltSTy);
   } else {
     const Type *ArrayEltTy = cast<ArrayType>(AllocaEltTy)->getElementType();
-    ArrayEltBitOffset = TD->getABITypeSizeInBits(ArrayEltTy);
+    ArrayEltBitOffset = TD->getTypePaddedSizeInBits(ArrayEltTy);
   }    
     
   Value *ResultVal = Constant::getNullValue(LI->getType());
@@ -1048,7 +1048,7 @@
   } else if (const VectorType *VTy = dyn_cast<VectorType>(Ty)) {
     return HasPadding(VTy->getElementType(), TD);
   }
-  return TD.getTypeSizeInBits(Ty) != TD.getABITypeSizeInBits(Ty);
+  return TD.getTypeSizeInBits(Ty) != TD.getTypePaddedSizeInBits(Ty);
 }
 
 /// isSafeStructAllocaToScalarRepl - Check to see if the specified allocation of
@@ -1270,7 +1270,7 @@
       // Check to see if this is stepping over an element: GEP Ptr, int C
       if (GEP->getNumOperands() == 2 && isa<ConstantInt>(GEP->getOperand(1))) {
         unsigned Idx = cast<ConstantInt>(GEP->getOperand(1))->getZExtValue();
-        unsigned ElSize = TD->getABITypeSize(PTy->getElementType());
+        unsigned ElSize = TD->getTypePaddedSize(PTy->getElementType());
         unsigned BitOffset = Idx*ElSize*8;
         if (BitOffset > 64 || !isPowerOf2_32(ElSize)) return 0;
         
@@ -1279,7 +1279,7 @@
         if (SubElt == 0) return 0;
         if (SubElt != Type::VoidTy && SubElt->isInteger()) {
           const Type *NewTy = 
-            getIntAtLeastAsBigAs(TD->getABITypeSizeInBits(SubElt)+BitOffset);
+            getIntAtLeastAsBigAs(TD->getTypePaddedSizeInBits(SubElt)+BitOffset);
           if (NewTy == 0 || MergeInType(NewTy, UsedType, *TD)) return 0;
           continue;
         }
@@ -1320,7 +1320,8 @@
         } else {
           return 0;
         }
-        const Type *NTy = getIntAtLeastAsBigAs(TD->getABITypeSizeInBits(AggTy));
+        const Type *NTy =
+          getIntAtLeastAsBigAs(TD->getTypePaddedSizeInBits(AggTy));
         if (NTy == 0 || MergeInType(NTy, UsedType, *TD)) return 0;
         const Type *SubTy = CanConvertToScalar(GEP, IsNotTrivial);
         if (SubTy == 0) return 0;
@@ -1396,7 +1397,7 @@
       const PointerType *AggPtrTy = 
         cast<PointerType>(GEP->getOperand(0)->getType());
       unsigned AggSizeInBits =
-        TD->getABITypeSizeInBits(AggPtrTy->getElementType());
+        TD->getTypePaddedSizeInBits(AggPtrTy->getElementType());
 
       // Check to see if this is stepping over an element: GEP Ptr, int C
       unsigned NewOffset = Offset;
@@ -1417,7 +1418,7 @@
       const Type *AggTy = AggPtrTy->getElementType();
       if (const SequentialType *SeqTy = dyn_cast<SequentialType>(AggTy)) {
         unsigned ElSizeBits =
-          TD->getABITypeSizeInBits(SeqTy->getElementType());
+          TD->getTypePaddedSizeInBits(SeqTy->getElementType());
 
         NewOffset += ElSizeBits*Idx;
       } else {
@@ -1471,7 +1472,7 @@
     // Otherwise it must be an element access.
     unsigned Elt = 0;
     if (Offset) {
-      unsigned EltSize = TD->getABITypeSizeInBits(VTy->getElementType());
+      unsigned EltSize = TD->getTypePaddedSizeInBits(VTy->getElementType());
       Elt = Offset/EltSize;
       Offset -= EltSize*Elt;
     }
@@ -1557,7 +1558,7 @@
       SV = new BitCastInst(SV, AllocaType, SV->getName(), SI);
     } else {
       // Must be an element insertion.
-      unsigned Elt = Offset/TD->getABITypeSizeInBits(PTy->getElementType());
+      unsigned Elt = Offset/TD->getTypePaddedSizeInBits(PTy->getElementType());
       SV = InsertElementInst::Create(Old, SV,
                                      ConstantInt::get(Type::Int32Ty, Elt),
                                      "tmp", SI);
diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp
index 6c59926..9a7f366 100644
--- a/lib/Transforms/Utils/LowerAllocations.cpp
+++ b/lib/Transforms/Utils/LowerAllocations.cpp
@@ -115,7 +115,8 @@
       // malloc(type) becomes sbyte *malloc(size)
       Value *MallocArg;
       if (LowerMallocArgToInteger)
-        MallocArg = ConstantInt::get(Type::Int64Ty, TD.getABITypeSize(AllocTy));
+        MallocArg = ConstantInt::get(Type::Int64Ty,
+                                     TD.getTypePaddedSize(AllocTy));
       else
         MallocArg = ConstantExpr::getSizeOf(AllocTy);
       MallocArg = ConstantExpr::getTruncOrBitCast(cast<Constant>(MallocArg),