aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-11-06 05:58:42 +0000
committerChris Lattner <sabre@nondot.org>2007-11-06 05:58:42 +0000
commitc0656ade71b07c320ca5633d7024e9ba69547783 (patch)
tree71bb8eaaaae7d171775060a9bc846ea52d9f2ab5 /lib/Analysis
parent9c88538126b554eb14405e98cfaedda6893a39d7 (diff)
downloadexternal_llvm-c0656ade71b07c320ca5633d7024e9ba69547783.zip
external_llvm-c0656ade71b07c320ca5633d7024e9ba69547783.tar.gz
external_llvm-c0656ade71b07c320ca5633d7024e9ba69547783.tar.bz2
Fix PR1774 and BasicAA/2007-11-05-SizeCrash.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43756 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index 6aeaec2..d13a333 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -753,9 +753,8 @@ BasicAliasAnalysis::CheckGEPInstructions(
//
if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
GEP1Ops[i] = ConstantInt::get(Type::Int64Ty,AT->getNumElements()-1);
- else if (const VectorType *PT = dyn_cast<VectorType>(BasePtr1Ty))
- GEP1Ops[i] = ConstantInt::get(Type::Int64Ty,PT->getNumElements()-1);
-
+ else if (const VectorType *VT = dyn_cast<VectorType>(BasePtr1Ty))
+ GEP1Ops[i] = ConstantInt::get(Type::Int64Ty,VT->getNumElements()-1);
}
}
@@ -765,8 +764,8 @@ BasicAliasAnalysis::CheckGEPInstructions(
if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) {
if (Op2C->getZExtValue() >= AT->getNumElements())
return MayAlias; // Be conservative with out-of-range accesses
- } else if (const VectorType *PT = dyn_cast<VectorType>(BasePtr1Ty)) {
- if (Op2C->getZExtValue() >= PT->getNumElements())
+ } else if (const VectorType *VT = dyn_cast<VectorType>(BasePtr1Ty)) {
+ if (Op2C->getZExtValue() >= VT->getNumElements())
return MayAlias; // Be conservative with out-of-range accesses
}
} else { // Conservatively assume the minimum value for this index
@@ -795,8 +794,13 @@ BasicAliasAnalysis::CheckGEPInstructions(
getTargetData().getIndexedOffset(GEPPointerTy, GEP1Ops, NumGEP1Ops);
int64_t Offset2 =
getTargetData().getIndexedOffset(GEPPointerTy, GEP2Ops, NumGEP2Ops);
- assert(Offset1<Offset2 && "There is at least one different constant here!");
-
+ assert(Offset1 != Offset2 &&
+ "There is at least one different constant here!");
+
+ // Make sure we compare the absolute difference.
+ if (Offset1 > Offset2)
+ std::swap(Offset1, Offset2);
+
if ((uint64_t)(Offset2-Offset1) >= SizeMax) {
//cerr << "Determined that these two GEP's don't alias ["
// << SizeMax << " bytes]: \n" << *GEP1 << *GEP2;