mirror of
https://github.com/intel/llvm.git
synced 2026-01-13 11:02:04 +08:00
[MLIR][Python][Transform] Print diagnostics also upon success (#172188)
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).
This commit is contained in:
@@ -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 " +
|
||||
|
||||
Reference in New Issue
Block a user