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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Feb 1 20:55:42 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Maksim Levental (makslevental)

<details>
<summary>Changes</summary>

#<!-- -->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.

---
Full diff: https://github.com/llvm/llvm-project/pull/179163.diff


1 Files Affected:

- (modified) mlir/lib/Bindings/Python/IRCore.cpp (+2-3) 


``````````diff
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(), ")")

``````````

</details>


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


More information about the Mlir-commits mailing list