[Mlir-commits] [mlir] 5916210 - [mlir] Find the pattern dump root only when IR debugging is enabled (#233771)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat Oct 24 08:14:04 PDT 2026
Author: Ivan Butygin
Date: 2026-10-24T18:13:59+03:00
New Revision: 5916210dbe10049c264ecf0a0ad685d101c392d9
URL: https://github.com/llvm/llvm-project/commit/5916210dbe10049c264ecf0a0ad685d101c392d9
DIFF: https://github.com/llvm/llvm-project/commit/5916210dbe10049c264ecf0a0ad685d101c392d9.diff
LOG: [mlir] Find the pattern dump root only when IR debugging is enabled (#233771)
Extracted from https://github.com/llvm/llvm-project/pull/231423
`PatternApplicator` debug printing was unconditionally calling
`getDumpRootOp` which walks nested ops chains. This was taking a
noticeable time in synthetic 1000-nested test. Call `getDumpRootOp` only
if printing is actually enabled.
Added:
Modified:
mlir/lib/Rewrite/PatternApplicator.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Rewrite/PatternApplicator.cpp b/mlir/lib/Rewrite/PatternApplicator.cpp
index e1b56fd6efda00..fc415e7dbb3847 100644
--- a/mlir/lib/Rewrite/PatternApplicator.cpp
+++ b/mlir/lib/Rewrite/PatternApplicator.cpp
@@ -200,7 +200,10 @@ LogicalResult PatternApplicator::matchAndRewrite(
#ifndef NDEBUG
// Operation `op` may be invalidated after applying the rewrite
// pattern.
- Operation *dumpRootOp = getDumpRootOp(op);
+ Operation *dumpRootOp = nullptr;
+ // Only find the dump root when level-2 IR debugging is enabled.
+ if (llvm::DebugFlag && llvm::isCurrentDebugType(DEBUG_TYPE, 2))
+ dumpRootOp = getDumpRootOp(op);
#endif
if (pdlMatch) {
result =
More information about the Mlir-commits
mailing list