================ @@ -572,20 +571,33 @@ bool GreedyPatternRewriteDriver::processWorklist() { logger.getOStream() << ")' {\n"; logger.indent(); }); + if (config.listener) + config.listener->notifyPatternBegin(pattern, op); return true; }; - auto onFailure = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("failure", "pattern failed to match")); - }; - auto onSuccess = [&](const Pattern &pattern) { - LLVM_DEBUG(logResult("success", "pattern applied successfully")); - return success(); - }; -#else - function_ref<bool(const Pattern &)> canApply = {}; - function_ref<void(const Pattern &)> onFailure = {}; - function_ref<LogicalResult(const Pattern &)> onSuccess = {}; -#endif + function_ref<void(const Pattern &)> onFailure = + [&](const Pattern &pattern) { + LLVM_DEBUG(logResult("failure", "pattern failed to match")); + if (config.listener) + config.listener->notifyPatternEnd(pattern, failure()); + }; + function_ref<LogicalResult(const Pattern &)> onSuccess = + [&](const Pattern &pattern) { + LLVM_DEBUG(logResult("success", "pattern applied successfully")); + if (config.listener) + config.listener->notifyPatternEnd(pattern, success()); + return success(); + }; + +#ifdef NDEBUG + // Optimization: PatternApplicator callbacks are not needed when running in + // optimized mode and without a listener. + if (!config.listener) { + canApply = nullptr; + onFailure = nullptr; + onSuccess = nullptr; + } +#endif // NDEBUG ---------------- joker-eph wrote:
Note: I didn't suggest changing this, what you had here was reasonable! https://github.com/llvm/llvm-project/pull/84131 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits