diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp --- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp +++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp @@ -1287,19 +1287,12 @@ return true; } - SmallVector Indices; - for (Use &Idx : GEP->indices()) { - if (auto *CIdx = dyn_cast(Idx)) { - Indices.push_back(CIdx); - continue; - } + APInt GEPOffset(DL.getIndexTypeSizeInBits(GEP->getType()), 0); + bool CannotFail = GEP->accumulateConstantOffset(DL, GEPOffset); + assert(CannotFail); + (void)CannotFail; - LLVM_DEBUG(dbgs() << "[AAPointerInfo] Non constant GEP index " << *GEP - << " : " << *Idx << "\n"); - return false; - } - UsrOI.Offset = PtrOI.Offset + DL.getIndexedOffsetInType( - GEP->getSourceElementType(), Indices); + UsrOI.Offset = PtrOI.Offset + GEPOffset.getZExtValue(); Follow = true; return true; }