diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp --- a/llvm/lib/Transforms/Scalar/SROA.cpp +++ b/llvm/lib/Transforms/Scalar/SROA.cpp @@ -3381,6 +3381,7 @@ getAdjustedAlignment(&LI, 0), DL); Value *V = UndefValue::get(LI.getType()); Splitter.emitSplitOps(LI.getType(), V, LI.getName() + ".fca"); + Visited.erase(&LI); LI.replaceAllUsesWith(V); LI.eraseFromParent(); return true; @@ -3427,6 +3428,7 @@ StoreOpSplitter Splitter(&SI, *U, V->getType(), AATags, getAdjustedAlignment(&SI, 0), DL); Splitter.emitSplitOps(V->getType(), V, V->getName() + ".fca"); + Visited.erase(&SI); SI.eraseFromParent(); return true; } @@ -3473,6 +3475,7 @@ Value *NSel = Builder.CreateSelect(Sel->getCondition(), NTrue, NFalse, Sel->getName() + ".sroa.sel"); + Visited.erase(&GEPI); GEPI.replaceAllUsesWith(NSel); GEPI.eraseFromParent(); Instruction *NSelI = cast(NSel); @@ -3521,6 +3524,7 @@ NewPN->addIncoming(NewVal, PHI->getIncomingBlock(I)); } + Visited.erase(&GEPI); GEPI.replaceAllUsesWith(NewPN); GEPI.eraseFromParent(); Visited.insert(NewPN);