diff --git a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp --- a/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp +++ b/mlir/lib/Dialect/Linalg/TransformOps/LinalgTransformOps.cpp @@ -1439,7 +1439,11 @@ DiagnosedSilenceableFailure PackGreedilyOp::apply(transform::TransformResults &transformResults, transform::TransformState &state) { - ArrayRef targetOps = state.getPayloadOps(getTarget()); + ArrayRef targetOpsView = state.getPayloadOps(getTarget()); + // Store payload ops into a separate SmallVector because the TrackingListener + // removes erased ops from the transform state. + SmallVector targetOps(targetOpsView.begin(), + targetOpsView.end()); SmallVector results; TrackingListener listener(state, *this); @@ -2773,7 +2777,10 @@ TrackingListener listener(state, *this); IRRewriter rewriter(getContext(), &listener); auto transformOp = cast(getOperation()); - ArrayRef targets = state.getPayloadOps(getTarget()); + ArrayRef targetsView = state.getPayloadOps(getTarget()); + // Store payload ops into a separate SmallVector because the TrackingListener + // removes erased ops from the transform state. + SmallVector targets(targetsView.begin(), targetsView.end()); // Result payload ops. SmallVector tileOps;