Skip to content

Commit

Permalink
[BasicAA] Turn DecomposeGEPExpression runtime checks into asserts.
Browse files Browse the repository at this point in the history
When it has a DataLayout, DecomposeGEPExpression() should return the same object
as GetUnderlyingObject(). Per the FIXME, it currently always has a DL, so the
runtime check is redundant and can become an assert.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270268 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
mkuperst committed May 20, 2016
1 parent bf0e75a commit 116261c
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions lib/Analysis/BasicAliasAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,13 +991,10 @@ AliasResult BasicAAResult::aliasGEP(const GEPOperator *GEP1, uint64_t V1Size,
const Value *GEP1BasePtr =
DecomposeGEPExpression(GEP1, GEP1BaseOffset, GEP1VariableIndices,
GEP1MaxLookupReached, DL, &AC, DT);
// DecomposeGEPExpression and GetUnderlyingObject should return the
// same result except when DecomposeGEPExpression has no DataLayout.
// FIXME: They always have a DataLayout, so this should become an
// assert.
if (GEP1BasePtr != UnderlyingV1 || GEP2BasePtr != UnderlyingV2) {
return MayAlias;
}

assert(GEP1BasePtr == UnderlyingV1 && GEP2BasePtr == UnderlyingV2 &&
"DecomposeGEPExpression returned a result different from "
"GetUnderlyingObject");
// If the max search depth is reached the result is undefined
if (GEP2MaxLookupReached || GEP1MaxLookupReached)
return MayAlias;
Expand Down Expand Up @@ -1029,12 +1026,10 @@ AliasResult BasicAAResult::aliasGEP(const GEPOperator *GEP1, uint64_t V1Size,
DecomposeGEPExpression(GEP2, GEP2BaseOffset, GEP2VariableIndices,
GEP2MaxLookupReached, DL, &AC, DT);

// DecomposeGEPExpression and GetUnderlyingObject should return the
// same result except when DecomposeGEPExpression has no DataLayout.
// FIXME: They always have a DataLayout, so this should become an assert.
if (GEP1BasePtr != UnderlyingV1 || GEP2BasePtr != UnderlyingV2) {
return MayAlias;
}
assert(GEP1BasePtr == UnderlyingV1 && GEP2BasePtr == UnderlyingV2 &&
"DecomposeGEPExpression returned a result different from "
"GetUnderlyingObject");


// If we know the two GEPs are based off of the exact same pointer (and not
// just the same underlying object), see if that tells us anything about
Expand Down Expand Up @@ -1081,10 +1076,10 @@ AliasResult BasicAAResult::aliasGEP(const GEPOperator *GEP1, uint64_t V1Size,

// DecomposeGEPExpression and GetUnderlyingObject should return the
// same result except when DecomposeGEPExpression has no DataLayout.
// FIXME: They always have a DataLayout, so this should become an assert.
if (GEP1BasePtr != UnderlyingV1) {
return MayAlias;
}
assert(GEP1BasePtr == UnderlyingV1 &&
"DecomposeGEPExpression returned a result different from "
"GetUnderlyingObject");

// If the max search depth is reached the result is undefined
if (GEP1MaxLookupReached)
return MayAlias;
Expand Down

0 comments on commit 116261c

Please sign in to comment.