This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Allow move-only RewritePattern arguments
AbandonedPublic

Authored by csigg on Jun 3 2021, 12:24 AM.

Details

Reviewers
rriddle

Diff Detail

Event Timeline

csigg created this revision.Jun 3 2021, 12:24 AM
csigg requested review of this revision.Jun 3 2021, 12:24 AM
rriddle added inline comments.Jun 3 2021, 3:17 PM
mlir/include/mlir/IR/PatternMatch.h
923

You should also forward the first arg.

csigg updated this revision to Diff 350038.Jun 5 2021, 1:20 AM

Also forward first argument.

Are the test failures related? They look like they might be.

csigg added a comment.Jun 8 2021, 11:55 PM

Are the test failures related? They look like they might be.

Yes, they are real. The arguments here are rvalues, so after the first pattern they are use-after-move.

I'm not sure if I want to proceed with this change. It might be safer to require using the add() overload on line 960 if pattern arguments are move-only. WDYT?

Are the test failures related? They look like they might be.

Yes, they are real. The arguments here are rvalues, so after the first pattern they are use-after-move.

I'm not sure if I want to proceed with this change. It might be safer to require using the add() overload on line 960 if pattern arguments are move-only. WDYT?

Yeah, I think that is a reasonable trade off. The other thing we could do is have an add<> overload for when there is only one pattern being added. We could keep the multi-pattern add the way it is now, but have the single-pattern one use perfect forwarding.

csigg added a comment.Jun 9 2021, 11:47 PM

The other thing we could do is have an add<> overload for when there is only one pattern being added. We could keep the multi-pattern add the way it is now, but have the single-pattern one use perfect forwarding.

Yes, that would be possible. But it only saves the 'std::make_unique' characters. Probably not worth it.

csigg abandoned this revision.Jun 9 2021, 11:48 PM