From 49813f7fbf5e18fb4bb15e8aaced27716e9366ba Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 29 Sep 2021 22:22:47 +0200 Subject: [PATCH] [BasicAA] Pass DecomposedGEP to constantOffsetHeuristic() (NFC) Rather than separately passing VarIndices and BaseOffset, pass the whole DecomposedGEP. --- llvm/include/llvm/Analysis/BasicAliasAnalysis.h | 5 ++--- llvm/lib/Analysis/BasicAliasAnalysis.cpp | 16 +++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h index 39ae5ff..41df8e5 100644 --- a/llvm/include/llvm/Analysis/BasicAliasAnalysis.h +++ b/llvm/include/llvm/Analysis/BasicAliasAnalysis.h @@ -196,9 +196,8 @@ private: /// However, we know that, for all %x, zext(%x) != zext(%x + 1), even if /// the addition overflows. bool - constantOffsetHeuristic(const SmallVectorImpl &VarIndices, - LocationSize V1Size, LocationSize V2Size, - const APInt &BaseOffset, AssumptionCache *AC, + constantOffsetHeuristic(const DecomposedGEP &GEP, LocationSize V1Size, + LocationSize V2Size, AssumptionCache *AC, DominatorTree *DT); bool isValueEqualInPotentialCycles(const Value *V1, const Value *V2); diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 911ea63..5e60cbe 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -1282,8 +1282,7 @@ AliasResult BasicAAResult::aliasGEP( } } - if (constantOffsetHeuristic(DecompGEP1.VarIndices, V1Size, V2Size, - DecompGEP1.Offset, &AC, DT)) + if (constantOffsetHeuristic(DecompGEP1, V1Size, V2Size, &AC, DT)) return AliasResult::NoAlias; } @@ -1772,17 +1771,16 @@ void BasicAAResult::GetIndexDifference( } bool BasicAAResult::constantOffsetHeuristic( - const SmallVectorImpl &VarIndices, - LocationSize MaybeV1Size, LocationSize MaybeV2Size, const APInt &BaseOffset, - AssumptionCache *AC, DominatorTree *DT) { - if (VarIndices.size() != 2 || !MaybeV1Size.hasValue() || + const DecomposedGEP &GEP, LocationSize MaybeV1Size, + LocationSize MaybeV2Size, AssumptionCache *AC, DominatorTree *DT) { + if (GEP.VarIndices.size() != 2 || !MaybeV1Size.hasValue() || !MaybeV2Size.hasValue()) return false; const uint64_t V1Size = MaybeV1Size.getValue(); const uint64_t V2Size = MaybeV2Size.getValue(); - const VariableGEPIndex &Var0 = VarIndices[0], &Var1 = VarIndices[1]; + const VariableGEPIndex &Var0 = GEP.VarIndices[0], &Var1 = GEP.VarIndices[1]; if (Var0.ZExtBits != Var1.ZExtBits || Var0.SExtBits != Var1.SExtBits || Var0.Scale != -Var1.Scale || Var0.V->getType() != Var1.V->getType()) @@ -1817,8 +1815,8 @@ bool BasicAAResult::constantOffsetHeuristic( // arithmetic (i.e. for some values of GEP1 and V2 GEP1 < V2, and for other // values GEP1 > V2). We'll therefore only declare NoAlias if both V1Size and // V2Size can fit in the MinDiffBytes gap. - return MinDiffBytes.uge(V1Size + BaseOffset.abs()) && - MinDiffBytes.uge(V2Size + BaseOffset.abs()); + return MinDiffBytes.uge(V1Size + GEP.Offset.abs()) && + MinDiffBytes.uge(V2Size + GEP.Offset.abs()); } //===----------------------------------------------------------------------===// -- 2.7.4