[MLIR][Python] fix getOwner to return (typed) nb::object instead of abstract PyOpView (#165053)

https://github.com/llvm/llvm-project/pull/157930 changed `nb::object
getOwner()` to `PyOpView getOwner()` which implicitly constructs the
generic OpView against from a (possibly) concrete OpView. This PR fixes
that.
This commit is contained in:
Maksim Levental
2025-10-25 21:48:46 -04:00
committed by GitHub
parent c8f5c602c8
commit c05ce9b005
2 changed files with 13 additions and 1 deletions

View File

@@ -1187,3 +1187,15 @@ def testOpWalk():
module.operation.walk(callback)
except RuntimeError:
print("Exception raised")
# CHECK-LABEL: TEST: testGetOwnerConcreteOpview
@run
def testGetOwnerConcreteOpview():
with Context() as ctx, Location.unknown():
module = Module.create()
with InsertionPoint(module.body):
a = arith.ConstantOp(value=42, result=IntegerType.get_signless(32))
r = arith.AddIOp(a, a, overflowFlags=arith.IntegerOverflowFlags.nsw)
for u in a.result.uses:
assert isinstance(u.owner, arith.AddIOp)