================
@@ -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:
The current approach should use a Mutex and serialize access. This does not
guarantee diagnostic ordering and can be annoying to users. AFAIK CIR doesn't
guarantee it now either since MLIR does not support it. So that is a pending
issue.
I believe long-term ordering belongs in MLIR pass mgr.
[OpToOpPassAdaptor::runOnOperationAsyncImpl](https://github.com/llvm/llvm-project/blob/main/mlir/lib/Pass/Pass.cpp#L913)
likely can use a parallel-for instead of a
[parallelForEach](https://github.com/llvm/llvm-project/blob/main/mlir/lib/Pass/Pass.cpp#L991)
and it should be possible to install a
[ParallelDiagnosticHandler](https://github.com/llvm/llvm-project/blob/f561d59856c1a2a1f7adb9604d47e9e1e940c7a0/mlir/include/mlir/IR/Diagnostics.h#L681)
and calling setOrderIDForThread(index) would be a feasible MLIR change.
Do you think we should purse this, if so I can go for it.
https://github.com/llvm/llvm-project/pull/199297
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits