[llvm-branch-commits] [mlir] [mlir][Transforms][NFC] Turn op creation into `IRRewrite` (PR #81759)

Matthias Springer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Feb 22 02:11:11 PST 2024


================
@@ -2549,10 +2572,15 @@ LogicalResult OperationConverter::legalizeConvertedArgumentTypes(
     });
     return liveUserIt == val.user_end() ? nullptr : *liveUserIt;
   };
-  for (auto &r : rewriterImpl.rewrites)
-    if (auto *rewrite = dyn_cast<BlockTypeConversionRewrite>(r.get()))
-      if (failed(rewrite->materializeLiveConversions(findLiveUser)))
+  // Note: `rewrites` may be reallocated as the loop is running.
+  for (int64_t i = 0; i < rewriterImpl.rewrites.size(); ++i) {
----------------
matthias-springer wrote:

That won't work here because things may get added to the vector while the loop is running and that could invalidate the iterator (when the vector reallocates storage).


https://github.com/llvm/llvm-project/pull/81759


More information about the llvm-branch-commits mailing list