aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2016-01-19 17:28:00 +0000
committerEduard Burtescu <edy.burt@gmail.com>2016-01-19 17:28:00 +0000
commit19eb03106d6042a404f4943f3e9efc74da6865f6 (patch)
tree77adf285682b322cf27b5955635970a6a0a332dc /llvm/lib/Analysis/ValueTracking.cpp
parentd9cac592f444c84b63797019975aefbac20e1985 (diff)
downloadllvm-19eb03106d6042a404f4943f3e9efc74da6865f6.zip
llvm-19eb03106d6042a404f4943f3e9efc74da6865f6.tar.gz
llvm-19eb03106d6042a404f4943f3e9efc74da6865f6.tar.bz2
[opaque pointer types] [NFC] GEP: replace get(Pointer)ElementType uses with get{Source,Result}ElementType.
Summary: GEPOperator: provide getResultElementType alongside getSourceElementType. This is made possible by adding a result element type field to GetElementPtrConstantExpr, which GetElementPtrInst already has. GEP: replace get(Pointer)ElementType uses with get{Source,Result}ElementType. Reviewers: mjacob, dblaikie Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D16275 llvm-svn: 258145
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 00c0e18..c7c86bc 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -2886,8 +2886,7 @@ bool llvm::getConstantStringInfo(const Value *V, StringRef &Str,
return false;
// Make sure the index-ee is a pointer to array of i8.
- PointerType *PT = cast<PointerType>(GEP->getOperand(0)->getType());
- ArrayType *AT = dyn_cast<ArrayType>(PT->getElementType());
+ ArrayType *AT = dyn_cast<ArrayType>(GEP->getSourceElementType());
if (!AT || !AT->getElementType()->isIntegerTy(8))
return false;
@@ -3253,8 +3252,7 @@ static bool isDereferenceableAndAlignedPointer(
// For GEPs, determine if the indexing lands within the allocated object.
if (const GEPOperator *GEP = dyn_cast<GEPOperator>(V)) {
- Type *VTy = GEP->getType();
- Type *Ty = VTy->getPointerElementType();
+ Type *Ty = GEP->getResultElementType();
const Value *Base = GEP->getPointerOperand();
// Conservatively require that the base pointer be fully dereferenceable
@@ -3265,14 +3263,14 @@ static bool isDereferenceableAndAlignedPointer(
Visited))
return false;
- APInt Offset(DL.getPointerTypeSizeInBits(VTy), 0);
+ APInt Offset(DL.getPointerTypeSizeInBits(GEP->getType()), 0);
if (!GEP->accumulateConstantOffset(DL, Offset))
return false;
// Check if the load is within the bounds of the underlying object
// and offset is aligned.
uint64_t LoadSize = DL.getTypeStoreSize(Ty);
- Type *BaseType = Base->getType()->getPointerElementType();
+ Type *BaseType = GEP->getSourceElementType();
assert(isPowerOf2_32(Align) && "must be a power of 2!");
return (Offset + LoadSize).ule(DL.getTypeAllocSize(BaseType)) &&
!(Offset & APInt(Offset.getBitWidth(), Align-1));