llvm-project
dc3fae37 - [MLIR] Emit final-policy remarks in deterministic order (#224616)

Commit
17 days ago
[MLIR] Emit final-policy remarks in deterministic order (#224616) `RemarkEmittingPolicyFinal` stores remarks in a `DenseSet` whose hash covers the location pointer and the process hash seed, so `finalize()` emitted them in bucket order. That order depends on the build configuration and on memory layout, which is why `mlir/test/Pass/remark-final.mlir` used `CHECK-DAG`. The engine already assigns every remark a `RemarkId` from a monotonic counter when it is created, and the set already keeps the newer of two remarks with the same identity. `finalize()` now sorts the drained remarks by that ID before emitting. Remarks come out in creation order, a replaced identity takes the position of its last report, and linked remarks still follow their parent. Behaviour change: order only. The identity, `DenseMapInfo<Remark>` and the header are unchanged. Only remarks handed to the policy outside the engine have no ID; the unit tests that do so assert unordered or single results. Creation order is deterministic for a single-threaded pipeline. When passes report from several threads the IDs come from a shared counter and depend on scheduling; #227360 adds the lock and a source-position sort for that case, on top of this change. Whether the identity itself is right is a separate question for a follow-up: the docs say a later `passed` replaces an earlier `failed` at the same location, but `kind` has been part of the key since #180953, so both are shown today. This PR leaves the docs as they are on that point. Assisted-by: Claude Code (Claude Fable 5.1).
Author
Parents
Loading