[all-commits] [llvm/llvm-project] 403a58: [MLIR][Remark] Make remark reporting thread-safe a...
Henrich Lauko via All-commits
all-commits at lists.llvm.org
Wed Sep 30 03:09:39 PDT 2026
Branch: refs/heads/users/xlauko/mlir-remark-thread-safe
Home: https://github.com/llvm/llvm-project
Commit: 403a58797d341cee1658381a71519b8913d25489
https://github.com/llvm/llvm-project/commit/403a58797d341cee1658381a71519b8913d25489
Author: Henrich Lauko <hlauko at nvidia.com>
Date: 2026-09-30 (Wed, 30 Sep 2026)
Changed paths:
M mlir/docs/Remarks.md
M mlir/include/mlir/IR/Remarks.h
M mlir/lib/IR/Remarks.cpp
M mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
A mlir/test/Pass/remark-final-parallel.mlir
M mlir/test/Pass/remark-final.mlir
M mlir/unittests/IR/RemarkTest.cpp
Log Message:
-----------
[MLIR][Remark] Make remark reporting thread-safe and order final remarks by source position
Passes nested under the multithreaded pass manager report into the same
RemarkEngine from worker threads, but nothing in the engine or the
policies was synchronized. RemarkEmittingPolicyFinal inserted into its
map from several threads at once, and under RemarkEmittingPolicyAll the
streamer, including the LLVM remark serializer, was called from several
threads at once. ThreadSanitizer reports both races in the new unit tests.
RemarkEngine now holds a lock around every call into the policy. It is a
recursive llvm::sys::SmartMutex, the same type as the DiagnosticEngine's
lock. report() takes it, and so does a new finalizePolicy(), which the
engine destructor and mlir-opt now use instead of calling finalize() on
the policy directly. For the All policy the streamer and the diagnostic
printer also run under the lock, so custom policies and streamers need no
lock of their own.
With the race fixed, the final policy's creation order is still not
deterministic: which thread reports first depends on scheduling.
finalize() now sorts root remarks by source position. The key is the file
positions nested in the location, in walk order, so the first is the one
the diagnostic printer shows and the rest separate one callee inlined at
different call sites. Remark name, category and kind follow, and the
printed location breaks any remaining tie. Remarks without a file position
come last. Identity and deduplication do not change, and linked remarks
still follow their parent.
remark-final.mlir swaps two CHECK lines: its remarks share a location and
a name, so the category now decides their order. New unit tests cover
source order, independence from report order, a linked remark at an
earlier position, and concurrent reporting under both policies. The new
lit test remark-final-parallel.mlir runs test-remark on four functions in
parallel and checks the same output with and without threading.
Assisted-by: Claude Code (Claude Opus 5.5)
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list