[llvm] r315294 - [SCCP] Fix mem-sanitizer failure introduced by r315288.

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 10 03:33:45 PDT 2017


Author: fhahn
Date: Tue Oct 10 03:33:45 2017
New Revision: 315294

URL: http://llvm.org/viewvc/llvm-project?rev=315294&view=rev
Log:
[SCCP] Fix mem-sanitizer failure introduced by r315288.


Modified:
    llvm/trunk/lib/Transforms/Scalar/SCCP.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=315294&r1=315293&r2=315294&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Tue Oct 10 03:33:45 2017
@@ -1600,8 +1600,10 @@ static bool tryToReplaceWithConstantRang
   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;
 




More information about the llvm-commits mailing list