[llvm] Use `std::move` to avoid copy (PR #113061)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 19 12:32:06 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-tablegen

Author: None (abhishek-kaushik22)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/113061.diff


5 Files Affected:

- (modified) llvm/utils/TableGen/ARMTargetDefEmitter.cpp (+1-1) 
- (modified) llvm/utils/TableGen/Common/CodeGenInstAlias.cpp (+1-1) 
- (modified) llvm/utils/TableGen/Common/CodeGenInstruction.cpp (+2-2) 
- (modified) llvm/utils/TableGen/CompressInstEmitter.cpp (+2-2) 
- (modified) llvm/utils/TableGen/OptionParserEmitter.cpp (+1-1) 


``````````diff
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 << ", ";

``````````

</details>


https://github.com/llvm/llvm-project/pull/113061


More information about the llvm-commits mailing list