[llvm-branch-commits] [llvm] 0d114f5 - [BasicAA] Return DecomposedGEP (NFC)
Nikita Popov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Nov 21 12:11:25 PST 2020
Author: Nikita Popov
Date: 2020-11-21T21:05:26+01:00
New Revision: 0d114f56d709792cc4230775c7da8a623d3a409a
URL: https://github.com/llvm/llvm-project/commit/0d114f56d709792cc4230775c7da8a623d3a409a
DIFF: https://github.com/llvm/llvm-project/commit/0d114f56d709792cc4230775c7da8a623d3a409a.diff
LOG: [BasicAA] Return DecomposedGEP (NFC)
Instead of requiring the caller to initialize the DecomposedGEP
structure and then passing it in by reference, make
DecomposeGEPExpression() responsible for initializing and returning
the structure.
Added:
Modified:
llvm/include/llvm/Analysis/BasicAliasAnalysis.h
llvm/lib/Analysis/BasicAliasAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
index 9e7950e4102e..3717fc9e2c36 100644
--- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h
@@ -168,8 +168,9 @@ class BasicAAResult : public AAResultBase<BasicAAResult> {
const DataLayout &DL, unsigned Depth, AssumptionCache *AC,
DominatorTree *DT, bool &NSW, bool &NUW);
- static bool DecomposeGEPExpression(const Value *V, DecomposedGEP &Decomposed,
- const DataLayout &DL, AssumptionCache *AC, DominatorTree *DT);
+ static DecomposedGEP
+ DecomposeGEPExpression(const Value *V, const DataLayout &DL,
+ AssumptionCache *AC, DominatorTree *DT);
static bool isGEPBaseAtNegativeOffset(const GEPOperator *GEPOp,
const DecomposedGEP &DecompGEP, const DecomposedGEP &DecompObject,
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 1cb207d4ccf0..89e1ad25ecbd 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -416,15 +416,17 @@ static unsigned getMaxPointerSize(const DataLayout &DL) {
/// can look through. To be able to do that getUnderlyingObject and
/// DecomposeGEPExpression must use the same search depth
/// (MaxLookupSearchDepth).
-bool BasicAAResult::DecomposeGEPExpression(const Value *V,
- DecomposedGEP &Decomposed, const DataLayout &DL, AssumptionCache *AC,
- DominatorTree *DT) {
+BasicAAResult::DecomposedGEP
+BasicAAResult::DecomposeGEPExpression(const Value *V, const DataLayout &DL,
+ AssumptionCache *AC, DominatorTree *DT) {
// Limit recursion depth to limit compile time in crazy cases.
unsigned MaxLookup = MaxLookupSearchDepth;
SearchTimes++;
unsigned MaxPointerSize = getMaxPointerSize(DL);
- Decomposed.VarIndices.clear();
+ DecomposedGEP Decomposed;
+ Decomposed.Offset = APInt(MaxPointerSize, 0);
+ Decomposed.HasCompileTimeConstantScale = true;
do {
// See if this is a bitcast or GEP.
const Operator *Op = dyn_cast<Operator>(V);
@@ -437,7 +439,7 @@ bool BasicAAResult::DecomposeGEPExpression(const Value *V,
}
}
Decomposed.Base = V;
- return false;
+ return Decomposed;
}
if (Op->getOpcode() == Instruction::BitCast ||
@@ -471,13 +473,13 @@ bool BasicAAResult::DecomposeGEPExpression(const Value *V,
}
Decomposed.Base = V;
- return false;
+ return Decomposed;
}
// Don't attempt to analyze GEPs over unsized objects.
if (!GEPOp->getSourceElementType()->isSized()) {
Decomposed.Base = V;
- return false;
+ return Decomposed;
}
// Don't attempt to analyze GEPs if index scale is not a compile-time
@@ -485,7 +487,7 @@ bool BasicAAResult::DecomposeGEPExpression(const Value *V,
if (isa<ScalableVectorType>(GEPOp->getSourceElementType())) {
Decomposed.Base = V;
Decomposed.HasCompileTimeConstantScale = false;
- return false;
+ return Decomposed;
}
unsigned AS = GEPOp->getPointerAddressSpace();
@@ -599,7 +601,7 @@ bool BasicAAResult::DecomposeGEPExpression(const Value *V,
// If the chain of expressions is too deep, just return early.
Decomposed.Base = V;
SearchLimitReached++;
- return true;
+ return Decomposed;
}
/// Returns whether the given pointer value points to memory that is local to
@@ -1217,15 +1219,8 @@ AliasResult BasicAAResult::aliasGEP(
const GEPOperator *GEP1, LocationSize V1Size, const AAMDNodes &V1AAInfo,
const Value *V2, LocationSize V2Size, const AAMDNodes &V2AAInfo,
const Value *UnderlyingV1, const Value *UnderlyingV2, AAQueryInfo &AAQI) {
- DecomposedGEP DecompGEP1, DecompGEP2;
- unsigned MaxPointerSize = getMaxPointerSize(DL);
- DecompGEP1.Offset = APInt(MaxPointerSize, 0);
- DecompGEP2.Offset = APInt(MaxPointerSize, 0);
- DecompGEP1.HasCompileTimeConstantScale =
- DecompGEP2.HasCompileTimeConstantScale = true;
-
- DecomposeGEPExpression(GEP1, DecompGEP1, DL, &AC, DT);
- DecomposeGEPExpression(V2, DecompGEP2, DL, &AC, DT);
+ DecomposedGEP DecompGEP1 = DecomposeGEPExpression(GEP1, DL, &AC, DT);
+ DecomposedGEP DecompGEP2 = DecomposeGEPExpression(V2, DL, &AC, DT);
// Don't attempt to analyze the decomposed GEP if index scale is not a
// compile-time constant.
More information about the llvm-branch-commits
mailing list