diff options
author | Dan Gohman <dan433584@gmail.com> | 2013-01-31 02:00:45 +0000 |
---|---|---|
committer | Dan Gohman <dan433584@gmail.com> | 2013-01-31 02:00:45 +0000 |
commit | 20a2ae9df595fc29d748f021dcc7872edde3f517 (patch) | |
tree | f2cd71338a87b2bd2fd1ee5a14fc5bb122fb20cf /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 37f7e18705f6ce4e41b343ec929f92a93cc65e21 (diff) | |
download | bcm5719-llvm-20a2ae9df595fc29d748f021dcc7872edde3f517.tar.gz bcm5719-llvm-20a2ae9df595fc29d748f021dcc7872edde3f517.zip |
Change GetPointerBaseWithConstantOffset's DataLayout argument from a
reference to a pointer, so that it can handle the case where DataLayout
is not available and behave conservatively.
llvm-svn: 174024
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 23bc4442f83..473ebc86174 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1671,8 +1671,10 @@ Value *llvm::FindInsertedValue(Value *V, ArrayRef<unsigned> idx_range, /// it can be expressed as a base pointer plus a constant offset. Return the /// base and offset to the caller. Value *llvm::GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, - const DataLayout &TD) { - unsigned BitWidth = TD.getPointerSizeInBits(); + const DataLayout *TD) { + // Without DataLayout, conservatively assume 64-bit offsets, which is + // the widest we support. + unsigned BitWidth = TD ? TD->getPointerSizeInBits() : 64; APInt ByteOffset(BitWidth, 0); while (1) { if (Ptr->getType()->isVectorTy()) @@ -1680,7 +1682,7 @@ Value *llvm::GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, if (GEPOperator *GEP = dyn_cast<GEPOperator>(Ptr)) { APInt GEPOffset(BitWidth, 0); - if (!GEP->accumulateConstantOffset(TD, GEPOffset)) + if (TD && !GEP->accumulateConstantOffset(*TD, GEPOffset)) break; ByteOffset += GEPOffset; Ptr = GEP->getPointerOperand(); |