summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2018-10-09 02:14:33 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2018-10-09 02:14:33 +0000
commitfefc42c9bbf44e755f213f494f263a52cbe12913 (patch)
treebdcd73245e412b92be8debb52f98a6c50fe82e19 /llvm/lib/Analysis/BasicAliasAnalysis.cpp
parent40a64c4c08d3c1f4c2cdca657d691c97bf09e580 (diff)
downloadbcm5719-llvm-fefc42c9bbf44e755f213f494f263a52cbe12913.tar.gz
bcm5719-llvm-fefc42c9bbf44e755f213f494f263a52cbe12913.zip
Use locals instead of struct fields; NFC
This is one of a series of changes intended to make https://reviews.llvm.org/D44748 more easily reviewable. Please see that patch for more context. Since I was requested to do all of this with post-commit review, this is about as small as I can make it (beyond committing changes to these few files separately, but they're incredibly similar in spirit, so...) On its own, this change doesn't make a great deal of sense. I plan on having a follow-up Real Soon Now(TM) to make the bits here make more sense. :) In particular, the next change in this series is meant to make LocationSize an actual type, which you have to call .getValue() on in order to get at the uint64_t inside. Hence, this change refactors code so that: - we only need to call the soon-to-come getValue() once in most cases, and - said call to getValue() happens very closely to a piece of code that checks if the LocationSize has a value (e.g. if it's != UnknownSize). llvm-svn: 344012
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index f9ecbc04326..6d4ac96ad37 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -1001,9 +1001,9 @@ ModRefInfo BasicAAResult::getModRefInfo(ImmutableCallSite CS1,
/// Provide ad-hoc rules to disambiguate accesses through two GEP operators,
/// both having the exact same pointer operand.
static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
- LocationSize V1Size,
+ LocationSize MaybeV1Size,
const GEPOperator *GEP2,
- LocationSize V2Size,
+ LocationSize MaybeV2Size,
const DataLayout &DL) {
assert(GEP1->getPointerOperand()->stripPointerCastsAndInvariantGroups() ==
GEP2->getPointerOperand()->stripPointerCastsAndInvariantGroups() &&
@@ -1019,10 +1019,13 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
// If we don't know the size of the accesses through both GEPs, we can't
// determine whether the struct fields accessed can't alias.
- if (V1Size == MemoryLocation::UnknownSize ||
- V2Size == MemoryLocation::UnknownSize)
+ if (MaybeV1Size == MemoryLocation::UnknownSize ||
+ MaybeV2Size == MemoryLocation::UnknownSize)
return MayAlias;
+ const uint64_t V1Size = MaybeV1Size;
+ const uint64_t V2Size = MaybeV2Size;
+
ConstantInt *C1 =
dyn_cast<ConstantInt>(GEP1->getOperand(GEP1->getNumOperands() - 1));
ConstantInt *C2 =
@@ -1179,11 +1182,14 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
// than (%alloca - 1), and so is not inbounds, a contradiction.
bool BasicAAResult::isGEPBaseAtNegativeOffset(const GEPOperator *GEPOp,
const DecomposedGEP &DecompGEP, const DecomposedGEP &DecompObject,
- LocationSize ObjectAccessSize) {
+ LocationSize MaybeObjectAccessSize) {
// If the object access size is unknown, or the GEP isn't inbounds, bail.
- if (ObjectAccessSize == MemoryLocation::UnknownSize || !GEPOp->isInBounds())
+ if (MaybeObjectAccessSize == MemoryLocation::UnknownSize ||
+ !GEPOp->isInBounds())
return false;
+ const uint64_t ObjectAccessSize = MaybeObjectAccessSize;
+
// We need the object to be an alloca or a globalvariable, and want to know
// the offset of the pointer from the object precisely, so no variable
// indices are allowed.
@@ -1418,7 +1424,9 @@ BasicAAResult::aliasGEP(const GEPOperator *GEP1, LocationSize V1Size,
// If we know all the variables are positive, then GEP1 >= GEP1BasePtr.
// If GEP1BasePtr > V2 (GEP1BaseOffset > 0) then we know the pointers
// don't alias if V2Size can fit in the gap between V2 and GEP1BasePtr.
- if (AllPositive && GEP1BaseOffset > 0 && V2Size <= (uint64_t)GEP1BaseOffset)
+ if (AllPositive && GEP1BaseOffset > 0 &&
+ V2Size != MemoryLocation::UnknownSize &&
+ V2Size <= (uint64_t)GEP1BaseOffset)
return NoAlias;
if (constantOffsetHeuristic(DecompGEP1.VarIndices, V1Size, V2Size,
@@ -1853,13 +1861,16 @@ void BasicAAResult::GetIndexDifference(
}
bool BasicAAResult::constantOffsetHeuristic(
- const SmallVectorImpl<VariableGEPIndex> &VarIndices, LocationSize V1Size,
- LocationSize V2Size, int64_t BaseOffset, AssumptionCache *AC,
- DominatorTree *DT) {
- if (VarIndices.size() != 2 || V1Size == MemoryLocation::UnknownSize ||
- V2Size == MemoryLocation::UnknownSize)
+ const SmallVectorImpl<VariableGEPIndex> &VarIndices,
+ LocationSize MaybeV1Size, LocationSize MaybeV2Size, int64_t BaseOffset,
+ AssumptionCache *AC, DominatorTree *DT) {
+ if (VarIndices.size() != 2 || MaybeV1Size == MemoryLocation::UnknownSize ||
+ MaybeV2Size == MemoryLocation::UnknownSize)
return false;
+ const uint64_t V1Size = MaybeV1Size;
+ const uint64_t V2Size = MaybeV2Size;
+
const VariableGEPIndex &Var0 = VarIndices[0], &Var1 = VarIndices[1];
if (Var0.ZExtBits != Var1.ZExtBits || Var0.SExtBits != Var1.SExtBits ||
OpenPOWER on IntegriCloud