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
..
2025-07-24 11:23:53 -07:00
2025-07-24 11:23:53 -07:00
2025-07-03 09:08:09 -07:00
2025-05-12 16:17:43 -07:00
2025-07-30 17:56:34 +02:00
2025-07-16 12:11:38 +02:00
2025-01-22 19:02:17 -05:00
2024-09-06 07:48:39 -07:00
2025-08-20 18:02:24 +02:00
2025-07-03 09:08:09 -07:00
2025-05-05 09:09:32 -07:00
2025-08-21 10:31:18 +00:00
2025-07-22 08:40:42 -04:00
2025-03-31 09:29:54 -07:00
2025-07-03 09:08:09 -07:00
2025-07-07 14:57:27 -04:00
2025-08-21 16:02:31 +02:00
2025-07-29 13:29:00 +02:00
2025-08-21 10:28:51 +00:00
2025-06-23 09:50:28 +02:00
2025-07-03 09:08:09 -07:00
2025-04-19 22:59:57 -04:00
2025-07-24 11:23:53 -07:00
2025-08-21 16:02:31 +02:00
2025-07-06 11:55:02 +02:00
2025-07-03 09:08:09 -07:00
2025-07-03 09:08:09 -07:00
2025-07-25 21:51:07 +02:00
2025-07-27 10:27:27 +02:00
2025-02-24 15:33:44 +01:00
2023-09-20 08:45:46 +02:00
2025-08-21 16:02:31 +02:00
2025-07-24 11:23:53 -07:00
2025-05-12 16:17:43 -07:00
2025-07-03 09:08:09 -07:00
2025-03-03 14:10:31 -06:00
2025-07-07 14:57:27 -04:00
2025-07-03 09:08:09 -07:00
2025-07-24 11:23:53 -07:00
2025-03-31 09:29:54 -07:00
2025-05-06 07:55:50 -07:00