[Mlir-commits] [mlir] 1e6f8aa - [mlir] MlirOptMain: avoid double verification (#192661)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Apr 20 04:02:40 PDT 2026
Author: Oleksandr "Alex" Zinenko
Date: 2026-04-20T11:02:35Z
New Revision: 1e6f8aafc75825ca80d60a17cda500a94640a1ba
URL: https://github.com/llvm/llvm-project/commit/1e6f8aafc75825ca80d60a17cda500a94640a1ba
DIFF: https://github.com/llvm/llvm-project/commit/1e6f8aafc75825ca80d60a17cda500a94640a1ba.diff
LOG: [mlir] MlirOptMain: avoid double verification (#192661)
MlirOptMain would run verification twice at the end of the processing:
1. after the last pass in the pipeline;
2. prior to printing. Since there is no logic that could mutate, and
thus potentially invalidate, the IR between the two, the second
verification is redundant. Skip it when possible.
Added:
Modified:
mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
mlir/test/Dialect/Transform/normal-forms.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index f90abda3463ab..56d2eb0f80185 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -621,8 +621,13 @@ performActions(raw_ostream &os,
if (config.bytecodeVersionToEmit().has_value())
return emitError(UnknownLoc::get(pm.getContext()))
<< "bytecode version while not emitting bytecode";
- AsmState asmState(op.get(), OpPrintingFlags(), /*locationMap=*/nullptr,
- &fallbackResourceMap);
+
+ // Don't re-run the verifier if we already ran the verifier at the end of the
+ // pass pipeline.
+ AsmState asmState(op.get(),
+ OpPrintingFlags().assumeVerified(
+ config.shouldVerifyPasses() && !pm.empty()),
+ /*locationMap=*/nullptr, &fallbackResourceMap);
os << OpWithState(op.get(), asmState) << '\n';
// This is required if the remark policy is final. Otherwise, the remarks are
diff --git a/mlir/test/Dialect/Transform/normal-forms.mlir b/mlir/test/Dialect/Transform/normal-forms.mlir
index 9c5cce81c133d..f651f199dea51 100644
--- a/mlir/test/Dialect/Transform/normal-forms.mlir
+++ b/mlir/test/Dialect/Transform/normal-forms.mlir
@@ -141,14 +141,12 @@ transform.payload attributes {
// 1. after the initial parsing (reasonable)
// 2. also in transform::detail::mergeSymbolsInto (has a TODO to be removed)
// 3. after the transform interpreter pass (reasonable)
-// 4. before printing (generally reasonable, but would be nice to avoid if
-// the IR is known-verified after by the pass manager).
// Notably this doesn't include an extra run from checkPayload, which is
// what we intend to test here.
// CHECK-LABEL: @verification_count
// CHECK: transform.payload
-// CHECK-SAME: test.counting_normal_form_count = 4
+// CHECK-SAME: test.counting_normal_form_count = 3
module @verification_count attributes {transform.with_named_sequence} {
transform.payload attributes {
More information about the Mlir-commits
mailing list