[TableGen] Avoid a couple vector copies in ExpandHwModeBasedTypes.

Use vector::swap instead of copying to a local vector and clearing
the original. We can just swap into the just created local vector
instead which will move the pointers and not the data.

Use std::move in another place to avoid a copy.
This commit is contained in:
Craig Topper 2021-01-30 12:19:14 -08:00
parent 26d38f6d20
commit 4e04a535d8
1 changed files with 5 additions and 4 deletions

View File

@ -4282,8 +4282,8 @@ static void collectModes(std::set<unsigned> &Modes, const TreePatternNode *N) {
void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
const CodeGenHwModes &CGH = getTargetInfo().getHwModes();
std::map<unsigned,std::vector<Predicate>> ModeChecks;
std::vector<PatternToMatch> Copy = PatternsToMatch;
PatternsToMatch.clear();
std::vector<PatternToMatch> Copy;
PatternsToMatch.swap(Copy);
auto AppendPattern = [this, &ModeChecks](PatternToMatch &P, unsigned Mode) {
TreePatternNodePtr NewSrc = P.SrcPattern->clone();
@ -4295,8 +4295,9 @@ void CodeGenDAGPatterns::ExpandHwModeBasedTypes() {
std::vector<Predicate> Preds = P.Predicates;
const std::vector<Predicate> &MC = ModeChecks[Mode];
llvm::append_range(Preds, MC);
PatternsToMatch.emplace_back(P.getSrcRecord(), Preds, std::move(NewSrc),
std::move(NewDst), P.getDstRegs(),
PatternsToMatch.emplace_back(P.getSrcRecord(), std::move(Preds),
std::move(NewSrc), std::move(NewDst),
P.getDstRegs(),
P.getAddedComplexity(), Record::getNewUID(),
Mode);
};