[ValueTracking] Add AllowNonInbounds parameter to GetPointerBaseWithConstantOffset function

This commit was part of D65402.

llvm-svn: 370016
This commit is contained in:
Hideto Ueno 2019-08-27 06:30:33 +00:00
parent c395c9172f
commit 8dad6157fb
1 changed files with 10 additions and 8 deletions

View File

@ -242,19 +242,21 @@ class Value;
/// This is a wrapper around Value::stripAndAccumulateConstantOffsets that
/// creates and later unpacks the required APInt.
inline Value *GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset,
const DataLayout &DL) {
const DataLayout &DL,
bool AllowNonInbounds = true) {
APInt OffsetAPInt(DL.getIndexTypeSizeInBits(Ptr->getType()), 0);
Value *Base =
Ptr->stripAndAccumulateConstantOffsets(DL, OffsetAPInt,
/* AllowNonInbounds */ true);
Ptr->stripAndAccumulateConstantOffsets(DL, OffsetAPInt, AllowNonInbounds);
Offset = OffsetAPInt.getSExtValue();
return Base;
}
inline const Value *GetPointerBaseWithConstantOffset(const Value *Ptr,
int64_t &Offset,
const DataLayout &DL) {
return GetPointerBaseWithConstantOffset(const_cast<Value *>(Ptr), Offset,
DL);
inline const Value *
GetPointerBaseWithConstantOffset(const Value *Ptr, int64_t &Offset,
const DataLayout &DL,
bool AllowNonInbounds = true) {
return GetPointerBaseWithConstantOffset(const_cast<Value *>(Ptr), Offset, DL,
AllowNonInbounds);
}
/// Returns true if the GEP is based on a pointer to a string (array of