diff options
author | Chris Lattner <sabre@nondot.org> | 2006-03-04 21:48:01 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-03-04 21:48:01 +0000 |
commit | 2cfdd2854c7bcc050758749a2e28e5f7b3c1b35f (patch) | |
tree | d6eba906d61d8c4b8f7d2afde9592c773eafa83c /lib/Analysis/BasicAliasAnalysis.cpp | |
parent | 9e14cd355f4b1b5222965c108ad2c750bc1c891a (diff) |
Fix a crash compiling Obsequi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index f10691e531..9a839ffdc5 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -637,17 +637,24 @@ CheckGEPInstructions(const Type* BasePtr1Ty, std::vector<Value*> &GEP1Ops, // than the first constant index of GEP2. // Advance BasePtr[12]Ty over this first differing constant operand. - BasePtr2Ty = cast<CompositeType>(BasePtr1Ty)->getTypeAtIndex(GEP2Ops[FirstConstantOper]); - BasePtr1Ty = cast<CompositeType>(BasePtr1Ty)->getTypeAtIndex(GEP1Ops[FirstConstantOper]); + BasePtr2Ty = cast<CompositeType>(BasePtr1Ty)-> + getTypeAtIndex(GEP2Ops[FirstConstantOper]); + BasePtr1Ty = cast<CompositeType>(BasePtr1Ty)-> + getTypeAtIndex(GEP1Ops[FirstConstantOper]); // We are going to be using TargetData::getIndexedOffset to determine the // offset that each of the GEP's is reaching. To do this, we have to convert // all variable references to constant references. To do this, we convert the - // initial equal sequence of variables into constant zeros to start with. - for (unsigned i = 0; i != FirstConstantOper; ++i) - if (!isa<ConstantInt>(GEP1Ops[i]) || !isa<ConstantInt>(GEP2Ops[i])) + // initial sequence of array subscripts into constant zeros to start with. + const Type *ZeroIdxTy = GEPPointerTy; + for (unsigned i = 0; i != FirstConstantOper; ++i) { + if (!isa<StructType>(ZeroIdxTy)) GEP1Ops[i] = GEP2Ops[i] = Constant::getNullValue(Type::UIntTy); + if (const CompositeType *CT = dyn_cast<CompositeType>(ZeroIdxTy)) + ZeroIdxTy = CT->getTypeAtIndex(GEP1Ops[i]); + } + // We know that GEP1Ops[FirstConstantOper] & GEP2Ops[FirstConstantOper] are ok // Loop over the rest of the operands... |