[llvm] 4e04a53 - [TableGen] Avoid a couple vector copies in ExpandHwModeBasedTypes.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 30 13:27:14 PST 2021
Author: Craig Topper
Date: 2021-01-30T13:16:39-08:00
New Revision: 4e04a535d8f836804d39e8861ae17d7817293c5a
URL: https://github.com/llvm/llvm-project/commit/4e04a535d8f836804d39e8861ae17d7817293c5a
DIFF: https://github.com/llvm/llvm-project/commit/4e04a535d8f836804d39e8861ae17d7817293c5a.diff
LOG: [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.
Added:
Modified:
llvm/utils/TableGen/CodeGenDAGPatterns.cpp
Removed:
################################################################################
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 1ca4a68eb155..d4409db2837e 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -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);
};
More information about the llvm-commits
mailing list