[PATCH] D34341: [TableGen] Fix bug in TableGen CodeGenPatterns when adding variants of the patterns.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 20 08:55:45 PDT 2017


craig.topper added a comment.

We don't need a new method to copy a vector. The caller can always make a copy into a local variable first.

What we should try to do is avoid inserting an extra copy of the vector. What we should try to do is make the copy occur before the vector is resized not after.

I proposed adding a move constructor not a copy constructor so that calling push_back(PatternToMatch(  will move the object into place after creating the object. This way the copy happens before and only moves happen after the vector is resized.

An alternative is to capture the DstRegs in a local variable and std::move it to the emplace_back call. Then we also need to change the signature of the constructor to take the vector by value and then std::move it into the class. This would require an audit and possible changes at all other uses of the constructor.

I think adding the move constructor is probably the simpler option.


https://reviews.llvm.org/D34341





More information about the llvm-commits mailing list