[Mlir-commits] [mlir] [MLIR] Integrate LLVM Optimization Remarks Infrastructure (PR #152474)
Mehdi Amini
llvmlistbot at llvm.org
Thu Aug 7 06:28:04 PDT 2025
================
@@ -387,6 +394,34 @@ bool MLIRContext::hasActionHandler() { return (bool)getImpl().actionHandler; }
/// Returns the diagnostic engine for this context.
DiagnosticEngine &MLIRContext::getDiagEngine() { return getImpl().diagEngine; }
+//===----------------------------------------------------------------------===//
+// Remark Handlers
+//===----------------------------------------------------------------------===//
+
+/// Returns the remark engine for this context.
+void MLIRContext::setRemarkEngine(std::unique_ptr<RemarkEngine> engine) {
+ getImpl().remarkEngine = std::move(engine);
+}
+
+std::unique_ptr<RemarkEngine> &MLIRContext::getRemarkEngine() {
+ return getImpl().remarkEngine;
+}
+
+void MLIRContext::setupOptimizationRemarks(
+ StringRef outputPath, StringRef outputFormat, bool printAsEmitRemarks,
+ const std::optional<std::string> &categoryPassName,
+ const std::optional<std::string> &categoryMissName,
+ const std::optional<std::string> &categoryAnalysisName,
+ const std::optional<std::string> &categoryFailedName) {
+ auto engine = std::make_unique<RemarkEngine>(
+ printAsEmitRemarks, categoryPassName, categoryMissName,
+ categoryAnalysisName, categoryFailedName);
+ llvm::Error e = engine->initialize(outputPath, outputFormat);
+ if (e)
+ llvm::report_fatal_error("Failed to initialize remark engine");
+ setRemarkEngine(std::move(engine));
+}
----------------
joker-eph wrote:
Since there is already a `setRemarkEngine`, I'm not sure sure this method is useful on the MLIRContext. The user could just initialize it separately themselves.
https://github.com/llvm/llvm-project/pull/152474
More information about the Mlir-commits
mailing list