This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Remove some copies around PatternToMatch.
ClosedPublic

Authored by craig.topper on Jun 20 2017, 9:53 AM.

Details

Summary

This patch does a few things that should remove some copies around PatternsToMatch. These were noticed while reviewing code for D34341.

Change constructor to take Dstregs by value and move it into the class. Change one of the callers to add std::move to the argument so that it gets moved.

Make AddPatternToMatch take PatternToMatch by rvalue reference so we can move it into the PatternsToMatch vector. I believe we should have a implicit default move constructor available on PatternToMatch. I chose rvalue reference because both callers call it with temporaries already.

Diff Detail

Event Timeline

craig.topper created this revision.Jun 20 2017, 9:53 AM
aymanmus edited edge metadata.Jun 21 2017, 4:06 AM

This mainly solves the problem described in D34341, only thing left is to change the call of emplace_back([argumetns]) with push_back(PatternToMatch([arguments])).
I'll update my patch and mark it as dependent with this one.

In the case of the PatternToMatch class (which includes only pointers, integers and a vector), I believe the move constructor would be implicitly declared by the compiler, and as the temp object passed to push_back is an rvalue, the implicit move constructor would be called.

aymanmus accepted this revision.Jun 25 2017, 12:38 AM
This revision is now accepted and ready to land.Jun 25 2017, 12:38 AM
craig.topper closed this revision.Jun 25 2017, 11:34 PM