]> granicus.if.org Git - llvm/commitdiff
[SCCP] Fix mem-sanitizer failure introduced by r315288.
authorFlorian Hahn <florian.hahn@arm.com>
Tue, 10 Oct 2017 10:33:45 +0000 (10:33 +0000)
committerFlorian Hahn <florian.hahn@arm.com>
Tue, 10 Oct 2017 10:33:45 +0000 (10:33 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@315294 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/SCCP.cpp

index b0f58367c94c907ad4a0ce7629741b718c5f782f..ca46b9016df63209da0299085a21cdb696bb05d1 100644 (file)
@@ -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;