diff options
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index efbab47406c..3c4cf1d88f9 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -3389,7 +3389,14 @@ Value *llvm::GetPointerBaseWithConstantOffset(Value *Ptr, int64_t &Offset, if (!GEP->accumulateConstantOffset(DL, GEPOffset)) break; - ByteOffset += GEPOffset.getSExtValue(); + APInt OrigByteOffset(ByteOffset); + ByteOffset += GEPOffset.sextOrTrunc(ByteOffset.getBitWidth()); + if (ByteOffset.getMinSignedBits() > 64) { + // Stop traversal if the pointer offset wouldn't fit into int64_t + // (this should be removed if Offset is updated to an APInt) + ByteOffset = OrigByteOffset; + break; + } Ptr = GEP->getPointerOperand(); } else if (Operator::getOpcode(Ptr) == Instruction::BitCast || |