Do not overrun iterators. This fixes a 176.gcc crash
authorChris Lattner <sabre@nondot.org>
Thu, 13 Jan 2005 23:26:48 +0000 (23:26 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 13 Jan 2005 23:26:48 +0000 (23:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19541 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/InstructionCombining.cpp

index b8ff3d4e7e73c5ff867b49c421ed9cadb01cc627..e8f52d11573cfc2b4541fed8ed52f1ae91ecc0d8 100644 (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)) {