Partially revert 279331, as we modify this instruction in the loop
authorDaniel Berlin <dberlin@dberlin.org>
Fri, 19 Aug 2016 22:18:38 +0000 (22:18 +0000)
committerDaniel Berlin <dberlin@dberlin.org>
Fri, 19 Aug 2016 22:18:38 +0000 (22:18 +0000)
llvm-svn: 279335

llvm/lib/Transforms/Scalar/SeparateConstOffsetFromGEP.cpp

index 961a3c1..62c9f46 100644 (file)
@@ -1150,9 +1150,13 @@ bool SeparateConstOffsetFromGEP::reuniteExts(Instruction *I) {
 bool SeparateConstOffsetFromGEP::reuniteExts(Function &F) {
   bool Changed = false;
   DominatingExprs.clear();
-  for (const auto Node : depth_first(DT))
-    for (auto &I : *(Node->getBlock()))
-      Changed |= reuniteExts(&I);
+  for (const auto Node : depth_first(DT)) {
+    BasicBlock *BB = Node->getBlock();
+    for (auto I = BB->begin(); I != BB->end(); ) {
+      Instruction *Cur = &*I++;
+      Changed |= reuniteExts(Cur);
+    }
+  }
   return Changed;
 }