@@ -3494,13 +3494,13 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
34943494 auto Removable =
34953495 isAllocSiteRemovable (&MI, Users, TLI, KnowInitZero | KnowInitUndef);
34963496 if (Removable) {
3497- for (unsigned i = 0 , e = Users. size (); i != e; ++i ) {
3497+ for (WeakTrackingVH &User : Users) {
34983498 // Lowering all @llvm.objectsize and MTI calls first because they may use
34993499 // a bitcast/GEP of the alloca we are removing.
3500- if (!Users[i] )
3501- continue ;
3500+ if (!User )
3501+ continue ;
35023502
3503- Instruction *I = cast<Instruction>(&*Users[i] );
3503+ Instruction *I = cast<Instruction>(&*User );
35043504
35053505 if (IntrinsicInst *II = dyn_cast<IntrinsicInst>(I)) {
35063506 if (II->getIntrinsicID () == Intrinsic::objectsize) {
@@ -3511,7 +3511,7 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
35113511 Worklist.add (Inserted);
35123512 replaceInstUsesWith (*I, Result);
35133513 eraseInstFromFunction (*I);
3514- Users[i] = nullptr ; // Skip examining in the next loop.
3514+ User = nullptr ; // Skip examining in the next loop.
35153515 continue ;
35163516 }
35173517 if (auto *MTI = dyn_cast<MemTransferInst>(I)) {
@@ -3527,11 +3527,11 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
35273527 }
35283528 }
35293529 }
3530- for (unsigned i = 0 , e = Users. size (); i != e; ++i ) {
3531- if (!Users[i] )
3530+ for (WeakTrackingVH &User : Users) {
3531+ if (!User )
35323532 continue ;
35333533
3534- Instruction *I = cast<Instruction>(&*Users[i] );
3534+ Instruction *I = cast<Instruction>(&*User );
35353535
35363536 if (ICmpInst *C = dyn_cast<ICmpInst>(I)) {
35373537 replaceInstUsesWith (*C,
0 commit comments