[Mlir-commits] [mlir] Make printing Value to a stream thread-safe (PR #185762)
Jacenty Andruszkiewicz
llvmlistbot at llvm.org
Wed Mar 11 10:48:37 PDT 2026
https://github.com/Jacenty-And-Intel updated https://github.com/llvm/llvm-project/pull/185762
>From 04fda5fb054a47c33d1f709639e16ffe0faa9335 Mon Sep 17 00:00:00 2001
From: "Andruszkiewicz, Jacenty" <jacenty.andruszkiewicz at intel.com>
Date: Tue, 10 Mar 2026 19:41:56 +0000
Subject: [PATCH] Make printing Value to a stream thread-safe
Adjust Value's operator<< and dump() function so that it can be safely used with multithreading enabled.
---
mlir/include/mlir/IR/Value.h | 5 +----
mlir/lib/IR/AsmPrinter.cpp | 7 ++++++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h
index af58778a0a13e..e72ace0920eb1 100644
--- a/mlir/include/mlir/IR/Value.h
+++ b/mlir/include/mlir/IR/Value.h
@@ -243,10 +243,7 @@ class Value {
detail::ValueImpl *impl;
};
-inline raw_ostream &operator<<(raw_ostream &os, Value value) {
- value.print(os);
- return os;
-}
+raw_ostream &operator<<(raw_ostream &os, Value value);
//===----------------------------------------------------------------------===//
// OpOperand
diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp
index b3242f838fc1d..5e9f6e87dfe08 100644
--- a/mlir/lib/IR/AsmPrinter.cpp
+++ b/mlir/lib/IR/AsmPrinter.cpp
@@ -4142,8 +4142,13 @@ void Value::print(raw_ostream &os, AsmState &state) const {
<< "' at index: " << arg.getArgNumber();
}
+raw_ostream &mlir::operator<<(raw_ostream &os, Value value) {
+ value.print(os, OpPrintingFlags().useLocalScope());
+ return os;
+}
+
void Value::dump() const {
- print(llvm::errs());
+ print(llvm::errs(), OpPrintingFlags().useLocalScope());
llvm::errs() << "\n";
}
More information about the Mlir-commits
mailing list