1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00

[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 b87f352cf4
commit 4312cea56a

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