Skip to content

Commit 31ce47b

Browse files
[TableGen] Use std::move to avoid copy (#113061)
1 parent 505e049 commit 31ce47b

9 files changed

+24
-21
lines changed

llvm/utils/TableGen/ARMTargetDefEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static void emitARMTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
223223
// Name of the object in C++
224224
const std::string CppSpelling = ArchInfoName(Major, Minor, ProfileUpper);
225225
OS << "inline constexpr ArchInfo " << CppSpelling << " = {\n";
226-
CppSpellings.push_back(CppSpelling);
226+
CppSpellings.push_back(std::move(CppSpelling));
227227

228228
OS << llvm::format(" VersionTuple{%d, %d},\n", Major, Minor);
229229
OS << llvm::format(" %sProfile,\n", ProfileUpper.c_str());

llvm/utils/TableGen/CallingConvEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,9 @@ void CallingConvEmitter::emitAction(const Record *Action, indent Indent,
163163
O << Indent << "if (MCRegister Reg = State.AllocateReg(" << Name
164164
<< ")) {\n";
165165
if (SwiftAction)
166-
AssignedSwiftRegsMap[CurrentAction].insert(Name);
166+
AssignedSwiftRegsMap[CurrentAction].insert(std::move(Name));
167167
else
168-
AssignedRegsMap[CurrentAction].insert(Name);
168+
AssignedRegsMap[CurrentAction].insert(std::move(Name));
169169
} else {
170170
O << Indent << "static const MCPhysReg RegList" << ++Counter
171171
<< "[] = {\n";

llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3183,7 +3183,8 @@ void TreePattern::dump() const { print(errs()); }
31833183
CodeGenDAGPatterns::CodeGenDAGPatterns(const RecordKeeper &R,
31843184
PatternRewriterFn PatternRewriter)
31853185
: Records(R), Target(R), Intrinsics(R),
3186-
LegalVTS(Target.getLegalValueTypes()), PatternRewriter(PatternRewriter) {
3186+
LegalVTS(Target.getLegalValueTypes()),
3187+
PatternRewriter(std::move(PatternRewriter)) {
31873188
ParseNodeInfo();
31883189
ParseNodeTransforms();
31893190
ParseComplexPatterns();

llvm/utils/TableGen/Common/CodeGenInstAlias.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ CodeGenInstAlias::CodeGenInstAlias(const Record *R, const CodeGenTarget &T)
228228
if (NumSubOps == 1 || (InstOpRec->getValue("ParserMatchClass") &&
229229
InstOpRec->getValueAsDef("ParserMatchClass")
230230
->getValueAsString("Name") != "Imm")) {
231-
ResultOperands.push_back(ResOp);
231+
ResultOperands.push_back(std::move(ResOp));
232232
ResultInstOperandIndex.push_back(std::pair(i, -1));
233233
++AliasOpNo;
234234

llvm/utils/TableGen/Common/CodeGenInstruction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
137137
" has the same name as a previous operand!");
138138

139139
OperandInfo &OpInfo = OperandList.emplace_back(
140-
Rec, std::string(ArgName), std::string(PrintMethod),
140+
Rec, std::string(ArgName), std::string(std::move(PrintMethod)),
141141
OperandNamespace + "::" + OperandType, MIOperandNo, NumOps, MIOpInfo);
142142

143143
if (SubArgDag) {
@@ -180,7 +180,7 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
180180
} else if (!EncoderMethod.empty()) {
181181
// If we have no explicit sub-op dag, but have an top-level encoder
182182
// method, the single encoder will multiple sub-ops, itself.
183-
OpInfo.EncoderMethodNames[0] = EncoderMethod;
183+
OpInfo.EncoderMethodNames[0] = std::move(EncoderMethod);
184184
for (unsigned j = 1; j < NumOps; ++j)
185185
OpInfo.DoNotEncode[j] = true;
186186
}

llvm/utils/TableGen/CompressInstEmitter.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ class CompressInstEmitter {
115115
CompressPat(const CodeGenInstruction &S, const CodeGenInstruction &D,
116116
std::vector<const Record *> RF, IndexedMap<OpData> &SourceMap,
117117
IndexedMap<OpData> &DestMap, bool IsCompressOnly)
118-
: Source(S), Dest(D), PatReqFeatures(RF), SourceOperandMap(SourceMap),
119-
DestOperandMap(DestMap), IsCompressOnly(IsCompressOnly) {}
118+
: Source(S), Dest(D), PatReqFeatures(std::move(RF)),
119+
SourceOperandMap(SourceMap), DestOperandMap(DestMap),
120+
IsCompressOnly(IsCompressOnly) {}
120121
};
121122
enum EmitterType { Compress, Uncompress, CheckCompress };
122123
const RecordKeeper &Records;
@@ -485,9 +486,9 @@ void CompressInstEmitter::evaluateCompressPat(const Record *Rec) {
485486
return R->getValueAsBit("AssemblerMatcherPredicate");
486487
});
487488

488-
CompressPatterns.push_back(CompressPat(SourceInst, DestInst, PatReqFeatures,
489-
SourceOperandMap, DestOperandMap,
490-
Rec->getValueAsBit("isCompressOnly")));
489+
CompressPatterns.push_back(CompressPat(
490+
SourceInst, DestInst, std::move(PatReqFeatures), SourceOperandMap,
491+
DestOperandMap, Rec->getValueAsBit("isCompressOnly")));
491492
}
492493

493494
static void
@@ -523,7 +524,7 @@ getReqFeatures(std::set<std::pair<bool, StringRef>> &FeaturesSet,
523524
}
524525

525526
if (IsOr)
526-
AnyOfFeatureSets.insert(AnyOfSet);
527+
AnyOfFeatureSets.insert(std::move(AnyOfSet));
527528
}
528529
}
529530

llvm/utils/TableGen/DecoderEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ OperandInfo getOpInfo(const Record *TypeRecord) {
18931893
bool HasCompleteDecoder =
18941894
HasCompleteDecoderBit ? HasCompleteDecoderBit->getValue() : true;
18951895

1896-
return OperandInfo(Decoder, HasCompleteDecoder);
1896+
return OperandInfo(std::move(Decoder), HasCompleteDecoder);
18971897
}
18981898

18991899
static void parseVarLenInstOperand(const Record &Def,
@@ -2024,7 +2024,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
20242024
EncodingDef.getValueAsBit("hasCompleteDecoder");
20252025
InsnOperands.push_back(
20262026
OperandInfo(std::string(InstDecoder), HasCompleteInstDecoder));
2027-
Operands[Opc] = InsnOperands;
2027+
Operands[Opc] = std::move(InsnOperands);
20282028
return Bits.getNumBits();
20292029
}
20302030

@@ -2059,7 +2059,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
20592059
MyName = Op.Name;
20602060

20612061
TiedNames[MyName] = TiedName;
2062-
TiedNames[TiedName] = MyName;
2062+
TiedNames[TiedName] = std::move(MyName);
20632063
}
20642064
}
20652065
}
@@ -2112,7 +2112,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
21122112

21132113
addOneOperandFields(EncodingDef, Bits, TiedNames, SubOpName,
21142114
SubOpInfo);
2115-
InsnOperands.push_back(SubOpInfo);
2115+
InsnOperands.push_back(std::move(SubOpInfo));
21162116
}
21172117
continue;
21182118
}
@@ -2143,7 +2143,7 @@ populateInstruction(const CodeGenTarget &Target, const Record &EncodingDef,
21432143
// instruction! (This is a longstanding bug, which will be addressed in an
21442144
// upcoming change.)
21452145
if (OpInfo.numFields() > 0)
2146-
InsnOperands.push_back(OpInfo);
2146+
InsnOperands.push_back(std::move(OpInfo));
21472147
}
21482148
}
21492149
Operands[Opc] = InsnOperands;

llvm/utils/TableGen/FastISelEmitter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ void FastISelMap::collectPatterns(const CodeGenDAGPatterns &CGP) {
567567
++DstIndex;
568568
}
569569

570-
PhysRegInputs.push_back(PhysReg);
570+
PhysRegInputs.push_back(std::move(PhysReg));
571571
}
572572

573573
if (Op->getName() != "EXTRACT_SUBREG" && DstIndex < Dst.getNumChildren())
@@ -591,7 +591,8 @@ void FastISelMap::collectPatterns(const CodeGenDAGPatterns &CGP) {
591591

592592
// Ok, we found a pattern that we can handle. Remember it.
593593
InstructionMemo Memo(Pattern.getDstPattern().getOperator()->getName(),
594-
DstRC, SubRegNo, PhysRegInputs, PredicateCheck);
594+
DstRC, std::move(SubRegNo), std::move(PhysRegInputs),
595+
PredicateCheck);
595596

596597
int complexity = Pattern.getPatternComplexity(CGP);
597598

llvm/utils/TableGen/OptionParserEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static void emitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
482482
HelpTextsForVariants.push_back(std::make_pair(
483483
VisibilityNames, VisibilityHelp->getValueAsString("Text")));
484484
}
485-
emitHelpTextsForVariants(OS, HelpTextsForVariants);
485+
emitHelpTextsForVariants(OS, std::move(HelpTextsForVariants));
486486

487487
// The option meta-variable name.
488488
OS << ", ";

0 commit comments

Comments
 (0)