This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][python bindings] implement `replace_all_uses_with` on `PyValue`
ClosedPublic

Authored by makslevental on Apr 20 2023, 10:20 AM.

Details

Summary

This diff adds replace_all_uses_with (replaceAllUsesWith) to the python api for PyValue, through the CAPI (mlirValueReplaceAllUsesOfWith). Plus house-keeping (dead code). Originally there was some discussion about whether the LiveOperationMap needs to be updated but I think we can skirt issue that by just "replacing" and then leaving elimination for a final dce pass (via the PassManager).

Diff Detail

Event Timeline

makslevental created this revision.Apr 20 2023, 10:20 AM
Herald added a project: Restricted Project. · View Herald Transcript

docs plus more dce

makslevental published this revision for review.Apr 20 2023, 10:31 AM
makslevental edited the summary of this revision. (Show Details)
makslevental added inline comments.Apr 20 2023, 10:36 AM
mlir/test/CAPI/ir.c
31–49

small factorization

1867–1875

I don't know why the order here is swapped - constOneValue is used in the previous block of tests (where dummy.op is created) so its first use should be dummy.op. Either the use_iterator is "confused" (not likely) or I am (likely).

makslevental edited the summary of this revision. (Show Details)Apr 20 2023, 10:44 AM
mehdi_amini added inline comments.Apr 24 2023, 7:46 AM
mlir/test/CAPI/ir.c
1867–1875

The use-list ordering is supposed to be an opaque implementation detail that can't be relied on.
In general they are added push_front to the use-list I think.

mehdi_amini accepted this revision.Apr 24 2023, 7:46 AM
This revision is now accepted and ready to land.Apr 24 2023, 7:46 AM
makslevental added inline comments.Apr 24 2023, 7:49 AM
mlir/test/CAPI/ir.c
1867–1875

So then mlirValueGetFirstUse should be something like mlirValueGetLatestUse?

This revision was landed with ongoing or failed builds.Apr 24 2023, 8:09 AM
This revision was automatically updated to reflect the committed changes.

Looks like this broke our ASAN bot: https://lab.llvm.org/buildbot/#/builders/168/builds/13141. Could you please revert or fix forward?

Thanks!

Looks like this broke our ASAN bot: https://lab.llvm.org/buildbot/#/builders/168/builds/13141. Could you please revert or fix forward?

Thanks!

Sorry just seeing this now - will revert.