llvm-project
c02e5de3 - [MLIR] Drain remarks in RemarkEmittingPolicyFinal::finalize() (#224607)

Commit
3 days ago
[MLIR] Drain remarks in RemarkEmittingPolicyFinal::finalize() (#224607) `RemarkEmittingPolicyFinal::finalize()` iterates `postponedRemarks` without clearing it. `MlirOptMain` calls `finalize()` after printing the module, and `~RemarkEngine` calls it again when the context is destroyed, so a YAML or bitstream streamer serializes every remark twice. With `mlir/test/Pass/remark-final.mlir` the YAML output file holds 10 records for 5 remarks. The console path hides this because the diagnostic handler is already gone when the destructor runs. This change swaps the pending set into a local before emitting. A second `finalize()` then emits only the remarks reported since the first one. A consequence worth stating: a `RelatedTo` link resolves only between remarks drained by the same call. Both behaviours are documented in the header comment and in `Remarks.md`. A follow-up will make the emission order of the final policy deterministic; today it is `DenseSet` iteration order, which is why the lit test keeps `CHECK-DAG`. Assisted-by: Claude Code (Claude Fable 5.1). I read and reviewed the change before opening it.
Author
Parents
Loading