Skip to content

Commit 78e0cca

Browse files
authored
[mlir] Fix debug output for passes that modify top-level operation. (#80022)
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
1 parent 0217d2e commit 78e0cca

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mlir/lib/Rewrite/PatternApplicator.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ static void logImpossibleToMatch(const Pattern &pattern) {
4040

4141
/// Log IR after pattern application.
4242
static Operation *getDumpRootOp(Operation *op) {
43-
return op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
43+
Operation *isolatedParent =
44+
op->getParentWithTrait<mlir::OpTrait::IsIsolatedFromAbove>();
45+
if (isolatedParent)
46+
return isolatedParent;
47+
return op;
4448
}
4549
static void logSucessfulPatternApplication(Operation *op) {
4650
llvm::dbgs() << "// *** IR Dump After Pattern Application ***\n";

0 commit comments

Comments
 (0)