diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/SCCP.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/SCCP.cpp b/llvm/lib/Transforms/Scalar/SCCP.cpp index b0f58367c94..ca46b9016df 100644 --- a/llvm/lib/Transforms/Scalar/SCCP.cpp +++ b/llvm/lib/Transforms/Scalar/SCCP.cpp @@ -1600,8 +1600,10 @@ static bool tryToReplaceWithConstantRange(SCCPSolver &Solver, Value *V) { if (!(V->getType()->isIntegerTy() && IV.isConstantRange())) return false; - for (auto &Use : V->uses()) { - auto *Icmp = dyn_cast<ICmpInst>(Use.getUser()); + for (auto UI = V->uses().begin(), E = V->uses().end(); UI != E;) { + // Advance the iterator here, as we might remove the current use. + const Use &U = *UI++; + auto *Icmp = dyn_cast<ICmpInst>(U.getUser()); if (!Icmp) continue; |