aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicAliasAnalysis.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-07-03 06:42:38 +0000
committerChris Lattner <sabre@nondot.org>2003-07-03 06:42:38 +0000
commit5bfccb9defee2026e113c1fd694eb29b99d4f8a6 (patch)
treee97db5a76def04b53ffbd953037dce97caf6b40b /lib/Analysis/BasicAliasAnalysis.cpp
parentc863c419031667f6d88e0799348633b0cce2870b (diff)
Reuse the values if they are constants: this is important so that we index into the right structure field
This fixes bug: BasicAA/2003-07-03-BasicAACrash.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r--lib/Analysis/BasicAliasAnalysis.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp
index b56782b506..8b34d25af4 100644
--- a/lib/Analysis/BasicAliasAnalysis.cpp
+++ b/lib/Analysis/BasicAliasAnalysis.cpp
@@ -288,8 +288,13 @@ BasicAliasAnalysis::CheckGEPInstructions(GetElementPtrInst *GEP1, unsigned G1S,
const Value *Op1 = GEP1->getOperand(i);
const Value *Op2 = GEP2->getOperand(i);
if (Op1 == Op2) { // If they are equal, use a zero index...
- Indices1.push_back(Constant::getNullValue(Op1->getType()));
- Indices2.push_back(Indices1.back());
+ if (!isa<Constant>(Op1)) {
+ Indices1.push_back(Constant::getNullValue(Op1->getType()));
+ Indices2.push_back(Indices1.back());
+ } else {
+ Indices1.push_back((Value*)Op1);
+ Indices2.push_back((Value*)Op2);
+ }
} else {
if (const ConstantInt *Op1C = dyn_cast<ConstantInt>(Op1)) {
// If this is an array index, make sure the array element is in range...