Skip to content

Commit 4e44166

Browse files
committed
[BasicAA][ValueTracking] Use MaxLookupSearchDepth constant (NFC)
Use MaxLookupSearchDepth in all places limiting an underlying object walk, instead of hardcoding 6 in various places.
1 parent b3db0c6 commit 4e44166

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

llvm/include/llvm/Analysis/ValueTracking.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ template <typename T> class ArrayRef;
4545

4646
constexpr unsigned MaxAnalysisRecursionDepth = 6;
4747

48+
/// The max limit of the search depth in DecomposeGEPExpression() and
49+
/// getUnderlyingObject().
50+
constexpr unsigned MaxLookupSearchDepth = 6;
51+
4852
/// Determine which bits of V are known to be either zero or one and return
4953
/// them in the KnownZero/KnownOne bit sets.
5054
///
@@ -432,9 +436,10 @@ LLVM_ABI bool isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(
432436
/// original object being addressed. Note that the returned value has pointer
433437
/// type if the specified value does. If the \p MaxLookup value is non-zero, it
434438
/// limits the number of instructions to be stripped off.
435-
LLVM_ABI const Value *getUnderlyingObject(const Value *V,
436-
unsigned MaxLookup = 6);
437-
inline Value *getUnderlyingObject(Value *V, unsigned MaxLookup = 6) {
439+
LLVM_ABI const Value *
440+
getUnderlyingObject(const Value *V, unsigned MaxLookup = MaxLookupSearchDepth);
441+
inline Value *getUnderlyingObject(Value *V,
442+
unsigned MaxLookup = MaxLookupSearchDepth) {
438443
// Force const to avoid infinite recursion.
439444
const Value *VConst = V;
440445
return const_cast<Value *>(getUnderlyingObject(VConst, MaxLookup));
@@ -475,7 +480,7 @@ LLVM_ABI const Value *getUnderlyingObjectAggressive(const Value *V);
475480
LLVM_ABI void getUnderlyingObjects(const Value *V,
476481
SmallVectorImpl<const Value *> &Objects,
477482
const LoopInfo *LI = nullptr,
478-
unsigned MaxLookup = 6);
483+
unsigned MaxLookup = MaxLookupSearchDepth);
479484

480485
/// This is a wrapper around getUnderlyingObjects and adds support for basic
481486
/// ptrtoint+arithmetic+inttoptr sequences.

llvm/lib/Analysis/BasicAliasAnalysis.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,6 @@ STATISTIC(SearchLimitReached, "Number of times the limit to "
7979
"decompose GEPs is reached");
8080
STATISTIC(SearchTimes, "Number of times a GEP is decomposed");
8181

82-
// The max limit of the search depth in DecomposeGEPExpression() and
83-
// getUnderlyingObject().
84-
static const unsigned MaxLookupSearchDepth = 6;
85-
8682
bool BasicAAResult::invalidate(Function &Fn, const PreservedAnalyses &PA,
8783
FunctionAnalysisManager::Invalidator &Inv) {
8884
// We don't care if this analysis itself is preserved, it has no state. But

0 commit comments

Comments
 (0)