-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[TableGen] Use std::move
to avoid copy
#113061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-tablegen Author: None (abhishek-kaushik22) ChangesFull diff: https://github.com/llvm/llvm-project/pull/113061.diff 5 Files Affected:
diff --git a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
index 6b8ebf96cdf383..752a1568bcfa3b 100644
--- a/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
+++ b/llvm/utils/TableGen/ARMTargetDefEmitter.cpp
@@ -208,7 +208,7 @@ static void EmitARMTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
// Name of the object in C++
const std::string CppSpelling = ArchInfoName(Major, Minor, ProfileUpper);
OS << "inline constexpr ArchInfo " << CppSpelling << " = {\n";
- CppSpellings.push_back(CppSpelling);
+ CppSpellings.push_back(std::move(CppSpelling));
OS << llvm::format(" VersionTuple{%d, %d},\n", Major, Minor);
OS << llvm::format(" %sProfile,\n", ProfileUpper.c_str());
diff --git a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
index 293ed76e0f5026..30694ac2bb2139 100644
--- a/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenInstAlias.cpp
@@ -228,7 +228,7 @@ CodeGenInstAlias::CodeGenInstAlias(const Record *R, const CodeGenTarget &T)
if (NumSubOps == 1 || (InstOpRec->getValue("ParserMatchClass") &&
InstOpRec->getValueAsDef("ParserMatchClass")
->getValueAsString("Name") != "Imm")) {
- ResultOperands.push_back(ResOp);
+ ResultOperands.push_back(std::move(ResOp));
ResultInstOperandIndex.push_back(std::pair(i, -1));
++AliasOpNo;
diff --git a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
index 1c0ab594d9310a..c6a2a0bfa3202a 100644
--- a/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenInstruction.cpp
@@ -137,7 +137,7 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
" has the same name as a previous operand!");
OperandInfo &OpInfo = OperandList.emplace_back(
- Rec, std::string(ArgName), std::string(PrintMethod),
+ Rec, std::string(ArgName), std::string(std::move(PrintMethod)),
OperandNamespace + "::" + OperandType, MIOperandNo, NumOps, MIOpInfo);
if (SubArgDag) {
@@ -180,7 +180,7 @@ CGIOperandList::CGIOperandList(const Record *R) : TheDef(R) {
} else if (!EncoderMethod.empty()) {
// If we have no explicit sub-op dag, but have an top-level encoder
// method, the single encoder will multiple sub-ops, itself.
- OpInfo.EncoderMethodNames[0] = EncoderMethod;
+ OpInfo.EncoderMethodNames[0] = std::move(EncoderMethod);
for (unsigned j = 1; j < NumOps; ++j)
OpInfo.DoNotEncode[j] = true;
}
diff --git a/llvm/utils/TableGen/CompressInstEmitter.cpp b/llvm/utils/TableGen/CompressInstEmitter.cpp
index e087ff07266380..dfdd1100a5fd83 100644
--- a/llvm/utils/TableGen/CompressInstEmitter.cpp
+++ b/llvm/utils/TableGen/CompressInstEmitter.cpp
@@ -115,7 +115,7 @@ class CompressInstEmitter {
CompressPat(const CodeGenInstruction &S, const CodeGenInstruction &D,
std::vector<const Record *> RF, IndexedMap<OpData> &SourceMap,
IndexedMap<OpData> &DestMap, bool IsCompressOnly)
- : Source(S), Dest(D), PatReqFeatures(RF), SourceOperandMap(SourceMap),
+ : Source(S), Dest(D), PatReqFeatures(std::move(RF)), SourceOperandMap(SourceMap),
DestOperandMap(DestMap), IsCompressOnly(IsCompressOnly) {}
};
enum EmitterType { Compress, Uncompress, CheckCompress };
@@ -523,7 +523,7 @@ getReqFeatures(std::set<std::pair<bool, StringRef>> &FeaturesSet,
}
if (IsOr)
- AnyOfFeatureSets.insert(AnyOfSet);
+ AnyOfFeatureSets.insert(std::move(AnyOfSet));
}
}
diff --git a/llvm/utils/TableGen/OptionParserEmitter.cpp b/llvm/utils/TableGen/OptionParserEmitter.cpp
index 2872762cc7fd96..7f70d9ed61bc0e 100644
--- a/llvm/utils/TableGen/OptionParserEmitter.cpp
+++ b/llvm/utils/TableGen/OptionParserEmitter.cpp
@@ -483,7 +483,7 @@ static void EmitOptionParser(const RecordKeeper &Records, raw_ostream &OS) {
HelpTextsForVariants.push_back(std::make_pair(
VisibilityNames, VisibilityHelp->getValueAsString("Text")));
}
- EmitHelpTextsForVariants(OS, HelpTextsForVariants);
+ EmitHelpTextsForVariants(OS, std::move(HelpTextsForVariants));
// The option meta-variable name.
OS << ", ";
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
std::move
to avoid copystd::move
to avoid copy
@arsenm Can you please review? |
arsenm
approved these changes
Nov 20, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.