Do not overrun iterators. This fixes a 176.gcc crash

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19541 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2005-01-13 23:26:48 +00:00
parent 79bda7fbe2
commit 0b84c80c08

View File

@ -2104,10 +2104,9 @@ static Value *EmitGEPOffset(User *GEP, Instruction &I, InstCombiner &IC) {
uint64_t PtrSizeMask = ~0ULL;
PtrSizeMask >>= 64-(TD.getPointerSize()*8);
++GTI; // Measure type stepping over.
for (unsigned i = 1, e = GEP->getNumOperands(); i != e; ++i, ++GTI) {
Value *Op = GEP->getOperand(i);
uint64_t Size = TD.getTypeSize(*GTI) & PtrSizeMask;
uint64_t Size = TD.getTypeSize(GTI.getIndexedType()) & PtrSizeMask;
Constant *Scale = ConstantExpr::getCast(ConstantUInt::get(UIntPtrTy, Size),
SIntPtrTy);
if (Constant *OpC = dyn_cast<Constant>(Op)) {