[all-commits] [llvm/llvm-project] 6b0bed: [MLIR] [Python] Add a method to clear live operati...

John Demme via All-commits all-commits at lists.llvm.org
Tue Apr 19 15:14:54 PDT 2022

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6b0bed7ea563624622c3c1fb1a3c90cd32c78db6
  Author: John Demme <john.demme at microsoft.com>
  Date:   2022-04-19 (Tue, 19 Apr 2022)

  Changed paths:
    M mlir/lib/Bindings/Python/IRCore.cpp
    M mlir/lib/Bindings/Python/IRModule.h
    M mlir/test/python/ir/module.py

  Log Message:
  [MLIR] [Python] Add a method to clear live operations map

Introduce a method on PyMlirContext (and plumb it through to Python) to
invalidate all of the operations in the live operations map and clear
it. Since Python has no notion of private data, an end-developer could
reach into some 3rd party API which uses the MLIR Python API (that is
behaving correctly with regard to holding references) and grab a
reference to an MLIR Python Operation, preventing it from being
deconstructed out of the live operations map. This allows the API
developer to clear the map when it calls C++ code which could delete
operations, protecting itself from its users.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D123895

More information about the All-commits mailing list