[PATCH] D39112: [CodeExtractor] Fix iterator invalidation in findOrCreateBlockForHoisting.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 31 14:37:49 PDT 2017


fhahn added inline comments.


================
Comment at: lib/Transforms/Utils/CodeExtractor.cpp:312
+       PI != PE;) {
+    BasicBlock *Pred = *PI++;
     if (Blocks.count(Pred))
----------------
davidxl wrote:
> Move ++ into the for clause?
I think we have to increment the iterator at the beginning of the loop, as replaceUsesOfWith may remove the element PI references and then the iterator would become invalid and `Transforms/CodeExtractor/live_shrink_hoist.ll` crashes.


https://reviews.llvm.org/D39112





More information about the llvm-commits mailing list