aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-03-04 16:40:17 +0000
committerChris Lattner <sabre@nondot.org>2003-03-04 16:40:17 +0000
commit506b4e4368601da94547990213fcd4efc4436163 (patch)
tree2a3ef5e4d06aa9dea238abf9f9b6727b69ae4204 /lib/Analysis/BasicAliasAnalysis.cpp
parent3fc7b6bd65efa5bc09080650d2a05abc2cf5f008 (diff)
Fix bug: BasicAA/2003-03-04-GEPCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5695 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index d9456f56e5..a0a685c7f8 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -274,24 +274,18 @@ BasicAliasAnalysis::CheckGEPInstructions(GetElementPtrInst *GEP1, unsigned G1S,
Indices1.push_back((Value*)Op1);
else {
// GEP1 is known to produce a value less than GEP2. To be
- // conservatively correct, we must assume the largest
- // possible constant is used in this position. This cannot
- // be the initial index to the GEP instructions (because we
- // know we have at least one element before this one with
- // the different constant arguments), so we know that the
- // current index must be into either a struct or array.
- // Because of this, we can calculate the maximum value
- // possible.
+ // conservatively correct, we must assume the largest possible constant
+ // is used in this position. This cannot be the initial index to the
+ // GEP instructions (because we know we have at least one element before
+ // this one with the different constant arguments), so we know that the
+ // current index must be into either a struct or array. Because we know
+ // it's not constant, this cannot be a structure index. Because of
+ // this, we can calculate the maximum value possible.
//
- const Type *ElTy = GEP1->getIndexedType(GEPPointerTy,
- Indices1, true);
- if (const StructType *STy = dyn_cast<StructType>(ElTy)) {
- Indices1.push_back(ConstantUInt::get(Type::UByteTy,
- STy->getNumContainedTypes()));
- } else {
- Indices1.push_back(ConstantSInt::get(Type::LongTy,
- cast<ArrayType>(ElTy)->getNumElements()));
- }
+ const ArrayType *ElTy =
+ cast<ArrayType>(GEP1->getIndexedType(GEPPointerTy, Indices1, true));
+ Indices1.push_back(ConstantSInt::get(Type::LongTy,
+ ElTy->getNumElements()-1));
}
if (isa<Constant>(Op2))