[mlir] reduce excessive verification in transform#192653
Merged
Merged
Conversation
Member
|
@llvm/pr-subscribers-mlir Author: Oleksandr "Alex" Zinenko (ftynse) Changes
Full diff: https://github.com/llvm/llvm-project/pull/192653.diff 2 Files Affected:
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 {
|
3878a1d to
f87489c
Compare
🐧 Linux x64 Test Results
✅ The build succeeded and all tests passed. |
🪟 Windows x64 Test Results
✅ The build succeeded and all tests passed. |
`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.
5cfed7f to
966ffea
Compare
martin-luecke
approved these changes
Apr 20, 2026
Contributor
martin-luecke
left a comment
There was a problem hiding this comment.
LGTM modulo typo in description: intead -> instead
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mergeSymbolsIntocalled 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.