Skip to content

[mlir] reduce excessive verification in transform#192653

Merged
ftynse merged 1 commit into
mainfrom
users/ftynse/transform-verify-less
Apr 20, 2026
Merged

[mlir] reduce excessive verification in transform#192653
ftynse merged 1 commit into
mainfrom
users/ftynse/transform-verify-less

Conversation

@ftynse
Copy link
Copy Markdown
Member

@ftynse ftynse commented Apr 17, 2026

mergeSymbolsInto called by the transform interpreter for named sequence management was calling a full verifier after renaming symbols. The renaming could have potentially broken symbol table-related invariants, but not really anything else. Only verify the symbol table-related invariants instead.

@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 17, 2026

@llvm/pr-subscribers-mlir

Author: Oleksandr "Alex" Zinenko (ftynse)

Changes

mergeSymbolsInto called by the transform interpreter for named sequence management was calling a full verifier after renaming symbols. The renaming could have potentially broken symbol table-related invariants, but not really anything else. Only verify the symbol table-related invariants intead.


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

2 Files Affected:

  • (modified) mlir/lib/Dialect/Transform/IR/Utils.cpp (+8-4)
  • (modified) mlir/test/Dialect/Transform/normal-forms.mlir (+4-5)
diff --git a/mlir/lib/Dialect/Transform/IR/Utils.cpp b/mlir/lib/Dialect/Transform/IR/Utils.cpp
index 773eb138cdf62..4c2f0ab376231 100644
--- a/mlir/lib/Dialect/Transform/IR/Utils.cpp
+++ b/mlir/lib/Dialect/Transform/IR/Utils.cpp
@@ -168,11 +168,12 @@ transform::detail::mergeSymbolsInto(Operation *target,
     }
   }
 
-  // TODO: This duplicates pass infrastructure. We should split this pass into
-  //       several and let the pass infrastructure do the verification.
+  // We only modified symbols above, so there is no need to verify everything
+  // again, just the symbol table.
   for (auto *op : SmallVector<Operation *>{target, *other}) {
-    if (failed(mlir::verify(op)))
-      return op->emitError() << "failed to verify input op after renaming";
+    if (failed(mlir::detail::verifySymbolTable(op)))
+      return op->emitError()
+             << "failed to verify symbol table after symbol renaming";
   }
 
   // Step 2:
@@ -234,6 +235,9 @@ transform::detail::mergeSymbolsInto(Operation *target,
     }
   }
 
+  // Need full verification here because merging/inlining may have broken some
+  // nesting invariants that were not broken in the sources.
+  // TODO: implement and use InlinerDialectInterface to avoid this check.
   if (failed(mlir::verify(target)))
     return target->emitError()
            << "failed to verify target op after merging symbols";
diff --git a/mlir/test/Dialect/Transform/normal-forms.mlir b/mlir/test/Dialect/Transform/normal-forms.mlir
index dfc6e4bdeb7b8..e66670e54bc23 100644
--- a/mlir/test/Dialect/Transform/normal-forms.mlir
+++ b/mlir/test/Dialect/Transform/normal-forms.mlir
@@ -139,16 +139,15 @@ transform.payload attributes {
 
 // We have surprisingly many invocations of the verifier here:
 //  1. after the initial parsing (reasonable)
-//  2. in transform::detail::mergeSymbolsInto (looks excessive)
-//  3. also in transform::detail::mergeSymbolsInto (has a TODO to be removed)
-//  4. after the transform interpreter pass (reasonable)
-//  5. before printing (generally reasonable, but would be nice to avoid if 
+//  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: transform.payload
-// CHECK-SAME: test.counting_normal_form_count = 5 : i64
+// CHECK-SAME: test.counting_normal_form_count = 4 : i64
 
 module attributes {transform.with_named_sequence} {
   transform.payload attributes {

@ftynse ftynse force-pushed the users/ftynse/transform-payload branch from 3878a1d to f87489c Compare April 17, 2026 14:05
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

🐧 Linux x64 Test Results

  • 7830 tests passed
  • 606 tests skipped

✅ The build succeeded and all tests passed.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

🪟 Windows x64 Test Results

  • 3625 tests passed
  • 417 tests skipped

✅ The build succeeded and all tests passed.

Base automatically changed from users/ftynse/transform-payload to main April 17, 2026 14:13
`mergeSymbolsInto` called by the transform interpreter for named
sequence management was calling a full verifier after renaming symbols.
The renaming could have potentially broken symbol table-related
invariants, but not really anything else. Only verify the symbol
table-related invariants intead.
@ftynse ftynse force-pushed the users/ftynse/transform-verify-less branch from 5cfed7f to 966ffea Compare April 17, 2026 14:34
@ftynse ftynse requested a review from martin-luecke April 17, 2026 22:02
Copy link
Copy Markdown
Contributor

@martin-luecke martin-luecke left a comment

Choose a reason for hiding this comment

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

LGTM modulo typo in description: intead -> instead

@ftynse ftynse merged commit 6fd5b52 into main Apr 20, 2026
10 checks passed
@ftynse ftynse deleted the users/ftynse/transform-verify-less branch April 20, 2026 08:52
KHicketts pushed a commit to KHicketts/llvm-project that referenced this pull request Apr 30, 2026
`mergeSymbolsInto` called by the transform interpreter for named
sequence management was calling a full verifier after renaming symbols.
The renaming could have potentially broken symbol table-related
invariants, but not really anything else. Only verify the symbol
table-related invariants instead.
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