This is an archive of the discontinued LLVM Phabricator instance.

[mlir][IR] Use Listener for IR callbacks in OperationFolder
ClosedPublic

Authored by springerm on Feb 21 2023, 2:42 AM.

Details

Summary

Remove the IR modification callbacks from OperationFolder. Instead, an optional RewriterBase::Listener can be specified.

  • processGeneratedConstants => notifyOperationCreated
  • preReplaceAction => notifyOperationReplaced

This simplifies the GreedyPatternRewriterDriver because we no longer need special handling for IR modifications due to op folding.

A folded operation is now enqueued on the GreedyPatternRewriteDriver's worklist if it was modified in-place. (There may be new patterns that apply after folding.)

Also fixes a bug in TestOpInPlaceFold::fold. The folder could previously be applied over and over and did not return a "null" OpFoldResult if the IR was not modified. (This is similar to a pattern that returns success without modifying IR; it can trigger an infinite loop in the GreedyPatternRewriteDriver.)

Depends On: D143380

Diff Detail

Event Timeline

springerm created this revision.Feb 21 2023, 2:42 AM
springerm requested review of this revision.Feb 21 2023, 2:42 AM
rriddle accepted this revision.Feb 22 2023, 9:21 AM
This revision is now accepted and ready to land.Feb 22 2023, 9:21 AM
This revision was landed with ongoing or failed builds.Feb 23 2023, 12:02 AM
This revision was automatically updated to reflect the committed changes.