This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Enable perfect forwarding in RewritePatternSet::add
ClosedPublic

Authored by laszlokindrat on Jul 12 2022, 3:24 PM.

Details

Summary

This patch modifies the implementation of RewritePatternSet::add to perfectly forward its arguments to pattern constructors. Without this, code like the following compiles but, due to the limited lifetime of the temporary TypeConverter, can produce unexpected behavior:

RewritePatternSet patterns(context);
patterns.add<SomeOpConversion, OtherOpConversion>(TypeConverter(), context);

if (failed(applyPartialConversion(getOperation(), target, std::move(patterns))))
  return signalPassFailure();

The patch also changes the linalg fusion pattern implementation to correctly fill the test pattern set given the new behavior.

Author: Laszlo Kindrat <laszlokindrat@gmail.com>

Diff Detail

Event Timeline

laszlokindrat created this revision.Jul 12 2022, 3:24 PM
laszlokindrat requested review of this revision.Jul 12 2022, 3:24 PM
nicolasvasilache accepted this revision.Jul 13 2022, 2:16 AM
This revision is now accepted and ready to land.Jul 13 2022, 2:16 AM
laszlokindrat edited the summary of this revision. (Show Details)Jul 13 2022, 6:13 AM

Could someone please land this? (I can't commit to the repo.) Thanks!

chelini reopened this revision.Jul 15 2022, 10:36 AM
This revision is now accepted and ready to land.Jul 15 2022, 10:36 AM
This revision was automatically updated to reflect the committed changes.