Skip to content

Conversation

@rolfmorel
Copy link
Contributor

If we do not collect the diagnostics from the
CollectDiagnosticsToStringScope, even when the named_sequence applied successfully, the Scope object's destructor will assert (with a unhelpful message).

If we do not collect the diagnostics from the
CollectDiagnosticsToStringScope, even when the named_sequence applied
successfully, the Scope object's destructor will assert (with a
unhelpful message).
@llvmbot
Copy link
Member

llvmbot commented Dec 14, 2025

@llvm/pr-subscribers-mlir

Author: Rolf Morel (rolfmorel)

Changes

If we do not collect the diagnostics from the
CollectDiagnosticsToStringScope, even when the named_sequence applied successfully, the Scope object's destructor will assert (with a unhelpful message).


Full diff: https://github.com/llvm/llvm-project/pull/172188.diff

1 Files Affected:

  • (modified) mlir/lib/Bindings/Python/TransformInterpreter.cpp (+11-2)
diff --git a/mlir/lib/Bindings/Python/TransformInterpreter.cpp b/mlir/lib/Bindings/Python/TransformInterpreter.cpp
index 920bca886f617..9e1eb37a816f6 100644
--- a/mlir/lib/Bindings/Python/TransformInterpreter.cpp
+++ b/mlir/lib/Bindings/Python/TransformInterpreter.cpp
@@ -14,8 +14,8 @@
 #include "mlir-c/IR.h"
 #include "mlir-c/Support.h"
 #include "mlir/Bindings/Python/Diagnostics.h"
-#include "mlir/Bindings/Python/NanobindAdaptors.h"
 #include "mlir/Bindings/Python/Nanobind.h"
+#include "mlir/Bindings/Python/NanobindAdaptors.h"
 
 namespace nb = nanobind;
 
@@ -70,8 +70,17 @@ static void populateTransformInterpreterSubmodule(nb::module_ &m) {
 
         MlirLogicalResult result = mlirTransformApplyNamedSequence(
             payloadRoot, transformRoot, transformModule, options.options);
-        if (mlirLogicalResultIsSuccess(result))
+        if (mlirLogicalResultIsSuccess(result)) {
+          // Even in cases of success, we might have diagnostics to report:
+          std::string msg;
+          if ((msg = scope.takeMessage()).size() > 0) {
+            fprintf(stderr,
+                    "Diagnostic generated while applying "
+                    "transform.named_sequence:\n%s",
+                    msg.data());
+          }
           return;
+        }
 
         throw nb::value_error(
             ("Failed to apply named transform sequence.\nDiagnostic message " +

Copy link
Contributor

@makslevental makslevental left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rolfmorel rolfmorel merged commit b33354f into llvm:main Dec 14, 2025
12 checks passed
anonymouspc pushed a commit to anonymouspc/llvm that referenced this pull request Dec 15, 2025
…72188)

If we do not collect the diagnostics from the
CollectDiagnosticsToStringScope, even when the named_sequence applied
successfully, the Scope object's destructor will assert (with a
unhelpful message).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants