Use type helper functions

llvm-svn: 191574
This commit is contained in:
Matt Arsenault 2013-09-27 22:18:51 +00:00
parent ff1b7ef31b
commit fa25272db9
3 changed files with 4 additions and 6 deletions

View File

@ -313,8 +313,7 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
}
// Don't attempt to analyze GEPs over unsized objects.
if (!cast<PointerType>(GEPOp->getOperand(0)->getType())
->getElementType()->isSized())
if (!GEPOp->getOperand(0)->getType()->getPointerElementType()->isSized())
return V;
// If we are lacking DataLayout information, we can't compute the offets of
@ -354,7 +353,7 @@ DecomposeGEPExpression(const Value *V, int64_t &BaseOffs,
// If the integer type is smaller than the pointer size, it is implicitly
// sign extended to pointer size.
unsigned Width = cast<IntegerType>(Index->getType())->getBitWidth();
unsigned Width = Index->getType()->getIntegerBitWidth();
if (TD->getPointerSizeInBits() > Width)
Extension = EK_SignExt;

View File

@ -1057,7 +1057,7 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) {
if (ParamPTy == 0 || !ParamPTy->getElementType()->isSized() || TD == 0)
return false;
Type *CurElTy = cast<PointerType>(ActTy)->getElementType();
Type *CurElTy = ActTy->getPointerElementType();
if (TD->getTypeAllocSize(CurElTy) !=
TD->getTypeAllocSize(ParamPTy->getElementType()))
return false;

View File

@ -1782,8 +1782,7 @@ Instruction *InstCombiner::visitICmpInstWithCastAndCast(ICmpInst &ICI) {
// Turn icmp (ptrtoint x), (ptrtoint/c) into a compare of the input if the
// integer type is the same size as the pointer type.
if (TD && LHSCI->getOpcode() == Instruction::PtrToInt &&
TD->getPointerSizeInBits() ==
cast<IntegerType>(DestTy)->getBitWidth()) {
TD->getPointerSizeInBits() == DestTy->getIntegerBitWidth()) {
Value *RHSOp = 0;
if (Constant *RHSC = dyn_cast<Constant>(ICI.getOperand(1))) {
RHSOp = ConstantExpr::getIntToPtr(RHSC, SrcTy);