[Mlir-commits] [mlir] [mlir] Don't use shared_ptr reference. (PR #202703)

Weiwei C llvmlistbot at llvm.org
Tue Jun 9 08:58:54 PDT 2026


https://github.com/weiweichen created https://github.com/llvm/llvm-project/pull/202703

`const std::share_ptr<...>&` doesn't increase ref count which can easily cause downstream user bugs with maintaining the life time of the object. Remove `&` to kick in ref count. 

>From cdb7b0e010cf718c908a7e84536a25902c03c004 Mon Sep 17 00:00:00 2001
From: Weiwei Chen <weiwei.chen at modular.com>
Date: Tue, 9 Jun 2026 11:55:37 -0400
Subject: [PATCH] [mlir] Don't use shared_ptr reference.

---
 mlir/lib/Bytecode/Reader/BytecodeReader.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
index 00c53dae83ea8..96ead28d0aa40 100644
--- a/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
+++ b/mlir/lib/Bytecode/Reader/BytecodeReader.cpp
@@ -1924,7 +1924,7 @@ class mlir::BytecodeReader::Impl {
 
   /// The optional owning source manager, which when present may be used to
   /// extend the lifetime of the input buffer.
-  const std::shared_ptr<llvm::SourceMgr> &bufferOwnerRef;
+  const std::shared_ptr<llvm::SourceMgr> bufferOwnerRef;
 };
 
 LogicalResult BytecodeReader::Impl::read(



More information about the Mlir-commits mailing list