Skip to content

Commit 02fb976

Browse files
authored
[mlir] Improve GreedyPatternRewriteDriver logging (llvm#127314)
Currently, when `GreedyPatternRewriteDriver` fails, the log output contains nested failure messages: ```bash } -> failure : pattern failed to match } -> failure : pattern failed to match ``` This may seem redundant, but these messages refer to different aspects of the pattern application logic. This patch clarifies the distinction by separately logging: * Success/failure for a specific pattern (e.g., "_this pattern_ failed to match on the Op currently being processed"). * Success/failure for an operation as a whole (e.g., "_all patterns_ failed to match the Op currently being processed"). Before (example with success): ```bash Processing operation : (...) { * Pattern (...) -> ()' { Trying to match "..." ** Match Failure : (...) } -> failure : pattern failed to match * Pattern (...) -> ()' { Trying to match "..." } -> success : pattern applied successfully } -> success : pattern matched ``` After (example with success): ```bash Processing operation : (...) { * Pattern (...) -> ()' { Trying to match "..." ** Match Failure : (...) } -> failure : pattern failed to match * Pattern (...) -> ()' { Trying to match "..." } -> success : pattern applied successfully } -> success : at least one pattern matched ``` This improves log clarity, making it easier to distinguish pattern-level failures from operation-level outcomes.
1 parent 07b0665 commit 02fb976

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,14 @@ bool GreedyPatternRewriteDriver::processWorklist() {
615615
matcher.matchAndRewrite(op, rewriter, canApply, onFailure, onSuccess);
616616

617617
if (succeeded(matchResult)) {
618-
LLVM_DEBUG(logResultWithLine("success", "pattern matched"));
618+
LLVM_DEBUG(logResultWithLine("success", "at least one pattern matched"));
619619
#if MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
620620
expensiveChecks.notifyRewriteSuccess();
621621
#endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
622622
changed = true;
623623
++numRewrites;
624624
} else {
625-
LLVM_DEBUG(logResultWithLine("failure", "pattern failed to match"));
625+
LLVM_DEBUG(logResultWithLine("failure", "all patterns failed to match"));
626626
#if MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS
627627
expensiveChecks.notifyRewriteFailure();
628628
#endif // MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS

0 commit comments

Comments
 (0)