[Mlir-commits] [mlir] [mlir][transform] Fix crash when op is erased during transform.foreach (PR #66357)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Thu Sep 14 04:09:35 PDT 2023
================
@@ -1121,8 +1121,11 @@ transform::ForeachOp::apply(transform::TransformRewriter &rewriter,
transform::TransformResults &results,
transform::TransformState &state) {
SmallVector<SmallVector<Operation *>> resultOps(getNumResults(), {});
-
- for (Operation *op : state.getPayloadOps(getTarget())) {
+ // Store payload ops in a vector because ops may be removed from the mapping
+ // by the TrackingRewriter while the iteration is in progress.
+ auto it = state.getPayloadOps(getTarget());
+ SmallVector<Operation *> targets(it.begin(), it.end());
----------------
ftynse wrote:
Nit: can this be `llvm::to_vector(state.getPayloadOps())` ?
https://github.com/llvm/llvm-project/pull/66357
More information about the Mlir-commits
mailing list