X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FTransforms%2FScalar%2FInstructionCombining.cpp;h=ee3596bde433d83a9805117befff6c17acbc6264;hp=49215317e267bb80d9433fdbaaa5fa4d8a04cd1b;hb=ceb4d1aecb9deffe59b3dcdc9a783ffde8477be9;hpb=ccca7fe6a30ec536de3823c0867806c1f86b2212 diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 49215317e26..ee3596bde43 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5142,7 +5142,7 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) { 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(Op)) { if (OpC->isZero()) continue; @@ -5233,7 +5233,7 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I, if (const StructType *STy = dyn_cast(*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 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I, 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 @@ static Value *EvaluateGEPOffsetExpression(User *GEP, Instruction &I, if (const StructType *STy = dyn_cast(*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 @@ Instruction *InstCombiner::PromoteCastOfAllocation(BitCastInst &CI, // 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 @@ static bool FindElementAtOffset(const Type *Ty, int64_t Offset, // 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 @@ static bool FindElementAtOffset(const Type *Ty, int64_t Offset, Offset -= SL->getElementOffset(Elt); Ty = STy->getElementType(Elt); } else if (const ArrayType *AT = dyn_cast(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 @@ Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) { // 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 @@ Instruction *InstCombiner::visitIntToPtr(IntToPtrInst &CI) { // "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 @@ static bool isSafeToEliminateVarargsCast(const CallSite CS, const Type* DstTy = cast(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 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { const Type *SrcElTy = cast(X->getType())->getElementType(); const Type *ResElTy=cast(PtrOp->getType())->getElementType(); if (isa(SrcElTy) && - TD->getABITypeSize(cast(SrcElTy)->getElementType()) == - TD->getABITypeSize(ResElTy)) { + TD->getTypePaddedSize(cast(SrcElTy)->getElementType()) == + TD->getTypePaddedSize(ResElTy)) { Value *Idx[2]; Idx[0] = Constant::getNullValue(Type::Int32Ty); Idx[1] = GEP.getOperand(1); @@ -10626,7 +10626,7 @@ Instruction *InstCombiner::visitGetElementPtrInst(GetElementPtrInst &GEP) { if (isa(SrcElTy) && ResElTy == Type::Int8Ty) { uint64_t ArrayEltSize = - TD->getABITypeSize(cast(SrcElTy)->getElementType()); + TD->getTypePaddedSize(cast(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 @@ Instruction *InstCombiner::visitAllocationInst(AllocationInst &AI) { // 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(AI) && AI.getAllocatedType()->isSized() && - TD->getABITypeSize(AI.getAllocatedType()) == 0) + TD->getTypePaddedSize(AI.getAllocatedType()) == 0) return ReplaceInstUsesWith(AI, Constant::getNullValue(AI.getType())); return 0;