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;
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 {
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) {
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();
}
}
// 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
// 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;
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;
// 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();
// "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();
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;
}
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);
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.
// 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;