[all-commits] [llvm/llvm-project] 688b48: [MLIR][Remark] Make remark reporting thread-safe a...

Henrich Lauko via All-commits all-commits at lists.llvm.org
Thu Oct 1 02:09:10 PDT 2026


  Branch: refs/heads/users/xlauko/mlir-remark-thread-safe
  Home:   https://github.com/llvm/llvm-project
  Commit: 688b48d25bf8f8327bc78363cfa218e187041965
      https://github.com/llvm/llvm-project/commit/688b48d25bf8f8327bc78363cfa218e187041965
  Author: Henrich Lauko <hlauko at nvidia.com>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M mlir/docs/Remarks.md
    M mlir/include/mlir/IR/Remarks.h
    M mlir/lib/IR/Remarks.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
set 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::report() now takes a lock, the same recursive
llvm::sys::SmartMutex the DiagnosticEngine uses. For the All policy the
streamer and the diagnostic printer run under it too, so custom policies
and streamers need no lock of their own. finalize() stays unlocked; it
runs once the pipeline has returned, as mlir-opt and the engine
destructor do.

With the race fixed, the final policy's creation order still depended on
which thread created a remark first. finalize() now sorts root remarks by
source position: the file position the diagnostic printer shows, remarks
without one last, then remark name, category and kind. Ties keep creation
order. The position comes from a new Remark::getFileLineColLoc(), which
print() and generateRemark() now share, so fused and named locations
serialize to YAML with their file position instead of "<unknown file>".
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, Claude Fable 5.1)



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