-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[mlir] Fix debug output for passes that modify top-level operation. #80022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Make it so that when the top-level (root) operation itself is being modified, it is also used as the root for debug output in PatternApplicator.
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-mlir Author: Robert Konicar (Jezurko) ChangesMake it so that when the top-level (root) operation itself is being modified, it is also used as the root for debug output in PatternApplicator. Full diff: https://github.com/llvm/llvm-project/pull/80022.diff 1 Files Affected:
diff --git a/mlir/lib/Rewrite/PatternApplicator.cpp b/mlir/lib/Rewrite/PatternApplicator.cpp
index 0064eb84aba84..686aef2e68e11 100644
--- a/mlir/lib/Rewrite/PatternApplicator.cpp
+++ b/mlir/lib/Rewrite/PatternApplicator.cpp
@@ -40,7 +40,9 @@ static void logImpossibleToMatch(const Pattern &pattern) {
/// Log IR after pattern application.
static Operation *getDumpRootOp(Operation *op) {
- return op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
+ return op->hasTrait<mlir::OpTrait::IsIsolatedFromAbove>()
+ ? op
+ : op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
}
static void logSucessfulPatternApplication(Operation *op) {
llvm::dbgs() << "// *** IR Dump After Pattern Application ***\n";
|
return op->hasTrait<mlir::OpTrait::IsIsolatedFromAbove>() | ||
? op | ||
: op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wish to fix the nullptr, I would likely write it as:
return op->hasTrait<mlir::OpTrait::IsIsolatedFromAbove>() | |
? op | |
: op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>(); | |
Operation *isolatedParent = op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>(); | |
if (isolatedParent) return isolatedParent; | |
return op; |
(That would preserve the current behavior in general)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change makes sense to me. If there is no isolated-from-above parent, we are modifying the top-level module and we should dump it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right, this is better. I have pushed an update
Make it so that when the top-level (root) operation itself is being modified, it is also used as the root for debug output in PatternApplicator.
Fix #80021