diff options
author | Chris Lattner <sabre@nondot.org> | 2003-12-11 06:02:00 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-12-11 06:02:00 +0000 |
commit | 88d3e03429bf3b0e78b1cccbad8a9246a7fdb23e (patch) | |
tree | 90f41b231d2b659ce31490a7ce67176f86fd186f /lib/Analysis | |
parent | 863914578a10d4cf83e1fdc5d7bc3242838c8e6f (diff) | |
download | external_llvm-88d3e03429bf3b0e78b1cccbad8a9246a7fdb23e.zip external_llvm-88d3e03429bf3b0e78b1cccbad8a9246a7fdb23e.tar.gz external_llvm-88d3e03429bf3b0e78b1cccbad8a9246a7fdb23e.tar.bz2 |
Realize the gep P, <zeros> must aliases P.
This is a partial fix for PR 86
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10399 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 3024917..b5a72f0 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -175,12 +175,22 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, // If there is at least one non-zero constant index, we know they cannot // alias. bool ConstantFound = false; + bool AllZerosFound = true; for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i) - if (const Constant *C = dyn_cast<Constant>(GEP->getOperand(i))) + if (const Constant *C = dyn_cast<Constant>(GEP->getOperand(i))) { if (!C->isNullValue()) { ConstantFound = true; break; + } + } else { + AllZerosFound = false; } + + // If we have getelementptr <ptr>, 0, 0, 0, 0, ... and V2 must aliases + // the ptr, the end result is a must alias also. + if (AllZerosFound) + return MustAlias; + if (ConstantFound) { if (V2Size <= 1 && V1Size <= 1) // Just pointer check? return NoAlias; |