[Mlir-commits] [mlir] [mlir][Python] fix liveContextMap under free-threading after #178529 (PR #179163)

Maksim Levental llvmlistbot at llvm.org
Sun Feb 1 20:55:12 PST 2026


https://github.com/makslevental created https://github.com/llvm/llvm-project/pull/179163

#178529 introduced a small bug under free-threading by bumping a reference count (or something like that) when accessing the operand list passed to `build_generic`. This PR fixes that.

>From 24a5b635c589a7b42510238a976dfbd74007193e Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Sun, 1 Feb 2026 20:53:41 -0800
Subject: [PATCH] [mlir][Python] fix liveContextMap under free-threading after
 178529

---
 mlir/lib/Bindings/Python/IRCore.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index dda4a027f0a30..466307c1488db 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1671,10 +1671,9 @@ nb::object PyOpView::buildGeneric(
       int segmentSpec = operandSegmentSpec[i];
       if (segmentSpec == 1 || segmentSpec == 0) {
         // Unpack unary element.
-        const auto operand = operandList[i];
-        if (!operand.is_none()) {
+        if (!operandList[i].is_none()) {
           try {
-            operands.push_back(getOpResultOrValue(operand));
+            operands.push_back(getOpResultOrValue(operandList[i]));
           } catch (nb::builtin_exception &err) {
             throw nb::value_error(join("Operand ", i, " of operation \"", name,
                                        "\" must be a Value (", err.what(), ")")



More information about the Mlir-commits mailing list