aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2016-07-11 01:32:20 +0000
committerHal Finkel <hfinkel@anl.gov>2016-07-11 01:32:20 +0000
commit5c12d8fe8f7ac9a3ec13ddad1561d63477e014f6 (patch)
treedd44cb608cfc199b1e9db70058b537669b386dcb /llvm/lib/Analysis/BasicAliasAnalysis.cpp
parent47646c09818bd3571d72b3f0e312b1f301ec66ee (diff)
downloadllvm-5c12d8fe8f7ac9a3ec13ddad1561d63477e014f6.zip
llvm-5c12d8fe8f7ac9a3ec13ddad1561d63477e014f6.tar.gz
llvm-5c12d8fe8f7ac9a3ec13ddad1561d63477e014f6.tar.bz2
BasicAA should look through functions with returned arguments
Motivated by the work on the llvm.noalias intrinsic, teach BasicAA to look through returned-argument functions when answering queries. This is essential so that we don't loose all other AA information when supplementing with llvm.noalias. Differential Revision: http://reviews.llvm.org/D9383 llvm-svn: 275035
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/BasicAliasAnalysis.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
index 7efcd724..43d5c3cc 100644
--- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -376,6 +376,12 @@ bool BasicAAResult::DecomposeGEPExpression(const Value *V,
const GEPOperator *GEPOp = dyn_cast<GEPOperator>(Op);
if (!GEPOp) {
+ if (auto CS = ImmutableCallSite(V))
+ if (const Value *RV = CS.getReturnedArgOperand()) {
+ V = RV;
+ continue;
+ }
+
// If it's not a GEP, hand it off to SimplifyInstruction to see if it
// can come up with something. This matches what GetUnderlyingObject does.
if (const Instruction *I = dyn_cast<Instruction>(V))
@@ -817,7 +823,10 @@ static AliasResult aliasSameBasePointerGEPs(const GEPOperator *GEP1,
uint64_t V2Size,
const DataLayout &DL) {
- assert(GEP1->getPointerOperand() == GEP2->getPointerOperand() &&
+ assert(GEP1->getPointerOperand()->stripPointerCasts() ==
+ GEP2->getPointerOperand()->stripPointerCasts() &&
+ GEP1->getPointerOperand()->getType() ==
+ GEP2->getPointerOperand()->getType() &&
"Expected GEPs with the same pointer operand");
// Try to determine whether GEP1 and GEP2 index through arrays, into structs,
@@ -1075,7 +1084,10 @@ AliasResult BasicAAResult::aliasGEP(const GEPOperator *GEP1, uint64_t V1Size,
// 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
// the resulting pointers.
- if (GEP1->getPointerOperand() == GEP2->getPointerOperand()) {
+ if (GEP1->getPointerOperand()->stripPointerCasts() ==
+ GEP2->getPointerOperand()->stripPointerCasts() &&
+ GEP1->getPointerOperand()->getType() ==
+ GEP2->getPointerOperand()->getType()) {
AliasResult R = aliasSameBasePointerGEPs(GEP1, V1Size, GEP2, V2Size, DL);
// If we couldn't find anything interesting, don't abandon just yet.
if (R != MayAlias)