================
@@ -52,6 +52,11 @@ void CIRGenerator::Initialize(ASTContext &astContext) {
   this->astContext = &astContext;
 
   mlirContext = std::make_unique<mlir::MLIRContext>();
+  // Disable MLIR multithreading: clang::DiagnosticsEngine is not thread-safe,
+  // and the per-context handler installed by CIRGenAction reports diagnostics
+  // straight through it. CIR's pass pipeline is short enough that we don't
+  // miss meaningful parallelism here.
+  mlirContext->disableMultithreading();
----------------
koparasy wrote:

I looked into this and I Enabled multithreading. It is Safe because the MLIR 
pass manager runs parallel op-pipelines through 
`mlir::ParallelDiagnosticHandler (Threading.h)`, which buffers each thread's 
diagnostics and re-emits them ( deterministically ordered ) on a single thread 
when it's destroyed. Only then do they reach the `CIRDiagnosticHandler` --> 
`clang::DiagnosticsEngine`, so the engine is never touched concurrently. 
Ordering also matches single-threaded output, so no interleaving regression.

https://github.com/llvm/llvm-project/pull/199297
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to