diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2021-03-15 11:51:23 +0300 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2021-03-15 11:52:31 +0300 |
commit | 36f1c3db66f7268ea3183bcf0bbf05b3e1c570b4 (patch) | |
tree | 5de177055f098ebfc5ff699c5f8dc991dac9de07 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 581672be04d15533caf7ec9830382219f78e4ce9 (diff) | |
download | llvm-36f1c3db66f7268ea3183bcf0bbf05b3e1c570b4.zip llvm-36f1c3db66f7268ea3183bcf0bbf05b3e1c570b4.tar.gz llvm-36f1c3db66f7268ea3183bcf0bbf05b3e1c570b4.tar.bz2 |
[NFCI][ValueTracking] getUnderlyingObject(): assert that no cycles are encountered
Jeroen Dobbelaere in
https://lists.llvm.org/pipermail/llvm-dev/2021-March/149206.html
is reporting that this function can end up in an endless loop
when called from SROA w/ full restrict patches.
For now, simply ensure that such problems are caught earlier/easier.
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 79399cf..8c44d73 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -4165,7 +4165,11 @@ static bool isSameUnderlyingObjectInLoop(const PHINode *PN, const Value *llvm::getUnderlyingObject(const Value *V, unsigned MaxLookup) { if (!V->getType()->isPointerTy()) return V; +#ifndef NDEBUG + SmallPtrSet<const Value *, 8> Visited; +#endif for (unsigned Count = 0; MaxLookup == 0 || Count < MaxLookup; ++Count) { + assert(Visited.insert(V).second && "Cycle detected. Unreachable code?"); if (auto *GEP = dyn_cast<GEPOperator>(V)) { V = GEP->getPointerOperand(); } else if (Operator::getOpcode(V) == Instruction::BitCast || |