aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ValueTracking.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2024-11-07 07:35:33 -0800
committerGitHub <noreply@github.com>2024-11-07 07:35:33 -0800
commitd74b1f029dcb7a89820cc5163925a113b10e64e2 (patch)
treea17da791bd1e780f5553704b0507b8485620b7a1 /llvm/lib/Analysis/ValueTracking.cpp
parent24e2e259a06d9aa67dc278ac24dcb98da9dd63f6 (diff)
downloadllvm-d74b1f029dcb7a89820cc5163925a113b10e64e2.zip
llvm-d74b1f029dcb7a89820cc5163925a113b10e64e2.tar.gz
llvm-d74b1f029dcb7a89820cc5163925a113b10e64e2.tar.bz2
ValueTracking: Do not return nullptr from getUnderlyingObject (#115258)
Fixup for 29a5c054e6d56a912ed5ba3f84e8ca631872db8b. The failure case should return the last value found.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r--llvm/lib/Analysis/ValueTracking.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 52d3468..f178e3a 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -6723,9 +6723,10 @@ static bool isSameUnderlyingObjectInLoop(const PHINode *PN,
const Value *llvm::getUnderlyingObject(const Value *V, unsigned MaxLookup) {
for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) {
if (auto *GEP = dyn_cast<GEPOperator>(V)) {
- V = GEP->getPointerOperand();
- if (!V->getType()->isPointerTy()) // Only handle scalar pointer base.
- return nullptr;
+ const Value *PtrOp = GEP->getPointerOperand();
+ if (!PtrOp->getType()->isPointerTy()) // Only handle scalar pointer base.
+ return V;
+ V = PtrOp;
} else if (Operator::getOpcode(V) == Instruction::BitCast ||
Operator::getOpcode(V) == Instruction::AddrSpaceCast) {
Value *NewV = cast<Operator>(V)->getOperand(0);