From: Matt Arsenault Date: Sat, 3 Aug 2013 01:03:12 +0000 (+0000) Subject: Minor address space code simplification. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=6b4dde71cfdcb2e1f2105dd8a677c14d8c3bb4b4;p=oota-llvm.git Minor address space code simplification. Remove assertion that the verifier should catch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187692 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/Transforms/Utils/Local.h b/include/llvm/Transforms/Utils/Local.h index 151dfa646b5..5e60286ba73 100644 --- a/include/llvm/Transforms/Utils/Local.h +++ b/include/llvm/Transforms/Utils/Local.h @@ -181,8 +181,7 @@ template Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &TD, User *GEP, bool NoAssumptions = false) { GEPOperator *GEPOp = cast(GEP); - unsigned AS = GEPOp->getPointerAddressSpace(); - Type *IntPtrTy = TD.getIntPtrType(GEP->getContext(), AS); + Type *IntPtrTy = TD.getIntPtrType(GEP->getType()); Value *Result = Constant::getNullValue(IntPtrTy); // If the GEP is inbounds, we know that none of the addressing operations will @@ -190,7 +189,7 @@ Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &TD, User *GEP, bool isInBounds = GEPOp->isInBounds() && !NoAssumptions; // Build a mask for high order bits. - unsigned IntPtrWidth = TD.getPointerSizeInBits(AS); + unsigned IntPtrWidth = IntPtrTy->getScalarType()->getIntegerBitWidth(); uint64_t PtrSizeMask = ~0ULL >> (64 - IntPtrWidth); gep_type_iterator GTI = gep_type_begin(GEP); diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp index c8a68274b15..b275dfe0a12 100644 --- a/lib/Analysis/InstructionSimplify.cpp +++ b/lib/Analysis/InstructionSimplify.cpp @@ -676,9 +676,8 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout *TD, if (!TD) return ConstantInt::get(IntegerType::get(V->getContext(), 64), 0); - unsigned AS = V->getType()->getPointerAddressSpace(); - unsigned IntPtrWidth = TD->getPointerSizeInBits(AS); - APInt Offset = APInt::getNullValue(IntPtrWidth); + Type *IntPtrTy = TD->getIntPtrType(V->getType())->getScalarType(); + APInt Offset = APInt::getNullValue(IntPtrTy->getIntegerBitWidth()); // Even though we don't look through PHI nodes, we could be called on an // instruction in an unreachable block, which may be on a cycle. @@ -690,11 +689,7 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout *TD, break; V = GEP->getPointerOperand(); } else if (Operator::getOpcode(V) == Instruction::BitCast) { - Value *Op0 = cast(V)->getOperand(0); - assert(TD->getPointerTypeSizeInBits(V->getType()) == - TD->getPointerTypeSizeInBits(Op0->getType()) && - "Bitcasting between pointers from different size address spaces"); - V = Op0; + V = cast(V)->getOperand(0); } else if (GlobalAlias *GA = dyn_cast(V)) { if (GA->mayBeOverridden()) break; @@ -706,7 +701,6 @@ static Constant *stripAndComputeConstantOffsets(const DataLayout *TD, "Unexpected operand type!"); } while (Visited.insert(V)); - Type *IntPtrTy = TD->getIntPtrType(V->getContext(), AS); Constant *OffsetIntPtr = ConstantInt::get(IntPtrTy, Offset); if (V->getType()->isVectorTy()) return ConstantVector::getSplat(V->getType()->getVectorNumElements(),