diff --git a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h --- a/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h +++ b/mlir/include/mlir/Dialect/Transform/IR/TransformInterfaces.h @@ -125,14 +125,14 @@ return result; } - /// Take the diagnostic and silence. - SmallVector &&takeDiagnostics() { + /// Take the diagnostics to and silence. + void takeDiagnostics(SmallVectorImpl &diags) { assert(!diagnostics.empty() && "expected a diagnostic to be present"); - auto guard = llvm::make_scope_exit([&]() { diagnostics.clear(); }); - return std::move(diagnostics); + diags.append(std::make_move_iterator(diagnostics.begin()), + std::make_move_iterator(diagnostics.end())); } - /// Streams the given values into the last diagnotic. + /// Streams the given values into the last diagnostic. /// Expects this object to be a silenceable failure. template DiagnosedSilenceableFailure &operator<<(T &&value) & { @@ -820,8 +820,7 @@ if (result.isDefiniteFailure()) return result; if (result.isSilenceableFailure()) - for (auto &&diag : result.takeDiagnostics()) - silenceableStack.push_back(std::move(diag)); + result.takeDiagnostics(silenceableStack); } if (!silenceableStack.empty()) { return DiagnosedSilenceableFailure::silenceableFailure( diff --git a/mlir/test/Dialect/Linalg/transform-op-pad.mlir b/mlir/test/Dialect/Linalg/transform-op-pad.mlir --- a/mlir/test/Dialect/Linalg/transform-op-pad.mlir +++ b/mlir/test/Dialect/Linalg/transform-op-pad.mlir @@ -93,7 +93,7 @@ transform.with_pdl_patterns { ^bb0(%arg0: !pdl.operation): - transform.sequence %arg0 failures(propagate) { + transform.sequence %arg0 failures(suppress) { ^bb1(%arg1: !pdl.operation): %0 = transform.structured.match ops{["linalg.matmul"]} in %arg1 // This error is silenceable and is not reported by this transform diff --git a/mlir/test/Dialect/Transform/test-interpreter.mlir b/mlir/test/Dialect/Transform/test-interpreter.mlir --- a/mlir/test/Dialect/Transform/test-interpreter.mlir +++ b/mlir/test/Dialect/Transform/test-interpreter.mlir @@ -550,6 +550,7 @@ func.func @foo() { "op" () { target_me } : () -> () + // expected-note @below {{when applied to this op}} "op" () : () -> () return } @@ -566,6 +567,7 @@ transform.sequence %arg0 failures(propagate) { ^bb0(%arg1: !pdl.operation): %0 = pdl_match @some in %arg1 + // expected-error @below {{failed to apply}} transform.test_mixed_sucess_and_silenceable %0 } }