[all-commits] [llvm/llvm-project] 38113a: [mlir][IR] Trigger `notifyOperationReplaced` on `r...

Matthias Springer via All-commits all-commits at lists.llvm.org
Mon Apr 1 18:54:19 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 38113a083283d2f30a677befaa5fb86dce731c8b
      https://github.com/llvm/llvm-project/commit/38113a083283d2f30a677befaa5fb86dce731c8b
  Author: Matthias Springer <me at m-sp.org>
  Date:   2024-04-02 (Tue, 02 Apr 2024)

  Changed paths:
    M mlir/include/mlir/IR/PatternMatch.h
    M mlir/lib/IR/PatternMatch.cpp
    M mlir/test/lib/Dialect/Test/TestPatterns.cpp

  Log Message:
  -----------
  [mlir][IR] Trigger `notifyOperationReplaced` on `replaceAllOpUsesWith` (#84721)

Before this change: `notifyOperationReplaced` was triggered when calling
`RewriteBase::replaceOp`.
After this change: `notifyOperationReplaced` is triggered when
`RewriterBase::replaceAllOpUsesWith` or `RewriterBase::replaceOp` is
called.

Until now, every `notifyOperationReplaced` was always sent together with
a `notifyOperationErased`, which made that `notifyOperationErased`
callback irrelevant. More importantly, when a user called
`RewriterBase::replaceAllOpUsesWith`+`RewriterBase::eraseOp` instead of
`RewriterBase::replaceOp`, no `notifyOperationReplaced` callback was
sent, even though the two notations are semantically equivalent. As an
example, this can be a problem when applying patterns with the transform
dialect because the `TrackingListener` will only see the
`notifyOperationErased` callback and the payload op is dropped from the
mappings.

Note: It is still possible to write semantically equivalent code that
does not trigger a `notifyOperationReplaced` (e.g., when op results are
replaced one-by-one), but this commit already improves the situation a
lot.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list