Guray Ozen
3d41197d68
[MLIR] Introduce RemarkEngine + pluggable remark streaming (YAML/Bitstream) (#152474)
This PR implements structured, tooling-friendly optimization remarks
with zero cost unless enabled. It implements:
- `RemarkEngine` collects finalized remarks within `MLIRContext`.
- `MLIRRemarkStreamerBase` abstract class streams them to a backend.
- Backends: `MLIRLLVMRemarkStreamer` (bridges to llvm::remarks →
YAML/Bitstream) or your own custom streamer.
- Optional mirroring to DiagnosticEngine (printAsEmitRemarks +
categories).
- Off by default; no behavior change unless enabled. Thread-safe;
ordering best-effort.
## Overview
```
Passes (reportOptimization*)
│
▼
+-------------------+
| RemarkEngine | collects
+-------------------+
│ │
│ mirror │ stream
▼ ▼
emitRemark MLIRRemarkStreamerBase (abstract)
│
├── MLIRLLVMRemarkStreamer → llvm::remarks → YAML | Bitstream
└── CustomStreamer → your sink
```
## Enable Remark engine and Plug LLVM's Remark streamer
```
// Enable once per MLIRContext. This uses `MLIRLLVMRemarkStreamer`
mlir::remark::enableOptimizationRemarksToFile(
ctx, path, llvm::remarks::Format::YAML, cats);
```
## API to emit remark
```
// Emit from a pass
remark::passed(loc, categoryVectorizer, myPassname1)
<< "vectorized loop";
remark::missed(loc, categoryUnroll, "MyPass")
<< remark::reason("not profitable at this size") // Creates structured reason arg
<< remark::suggest("increase unroll factor to >=4"); // Creates structured suggestion arg
remark::passed(loc, categoryVectorizer, myPassname1)
<< "vectorized loop"
<< remark::metric("tripCount", 128); // Create structured metric on-the-fly
```
2025-08-21 16:02:31 +02:00
..
2024-04-22 13:42:05 -07:00
2025-07-04 23:34:07 +03:00
2024-11-26 13:01:02 +00:00
2025-07-29 17:13:03 +02:00
2024-07-12 09:24:01 -07:00
2025-06-23 09:50:28 +02:00
2025-08-21 16:02:31 +02:00
2024-10-15 10:38:45 -07:00
2024-08-06 01:32:36 +02:00
2025-07-16 12:11:38 +02:00
2025-07-25 11:48:17 -05:00
2025-07-25 11:48:17 -05:00
2025-07-25 11:48:17 -05:00
2024-10-03 10:25:44 -07:00
2025-06-23 09:28:33 +01:00
2025-07-25 11:48:17 -05:00
2025-04-20 16:36:35 -07:00
2025-03-06 08:48:51 +01:00
2025-08-21 16:02:31 +02:00
2025-02-27 17:59:27 -08:00
2025-07-29 10:32:14 +01:00
2023-12-01 00:39:34 +01:00
2023-12-01 00:39:34 +01:00
2025-07-18 13:32:56 -07:00