Be more careful modifying the use_list while also iterating through it.

llvm-svn: 46417
diff --git a/llvm/lib/Transforms/Scalar/LoopUnroll.cpp b/llvm/lib/Transforms/Scalar/LoopUnroll.cpp
index ff2168a..b514156 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnroll.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnroll.cpp
@@ -365,8 +365,9 @@
       // be updated specially after unrolling all the way.
       if (*BB != LatchBlock)
         for (Value::use_iterator UI = (*BB)->use_begin(), UE = (*BB)->use_end();
-             UI != UE; ++UI) {
+             UI != UE;) {
           Instruction *UseInst = cast<Instruction>(*UI);
+          ++UI;
           if (isa<PHINode>(UseInst) && !L->contains(UseInst->getParent())) {
             PHINode *phi = cast<PHINode>(UseInst);
             Value *Incoming = phi->getIncomingValueForBlock(*BB);