Skip to content

[NFC] Use std::move to avoid copy #134531

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

abhishek-kaushik22
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Apr 6, 2025

@llvm/pr-subscribers-tablegen

@llvm/pr-subscribers-backend-x86

Author: Abhishek Kaushik (abhishek-kaushik22)

Changes

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

3 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/SelectionDAGNodes.h (+2-2)
  • (modified) llvm/lib/Target/X86/X86ISelLowering.cpp (+1-1)
  • (modified) llvm/utils/TableGen/SubtargetEmitter.cpp (+2-1)
diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
index 2283f99202e2f..38b4ba89e26e6 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -3296,8 +3296,8 @@ namespace ISD {
                                   std::function<bool(ConstantSDNode *)> Match,
                                   bool AllowUndefs = false,
                                   bool AllowTruncation = false) {
-    return matchUnaryPredicateImpl<ConstantSDNode>(Op, Match, AllowUndefs,
-                                                   AllowTruncation);
+    return matchUnaryPredicateImpl<ConstantSDNode>(
+        Op, std::move(Match), AllowUndefs, AllowTruncation);
   }
 
   /// Hook for matching ConstantFPSDNode predicate
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 02398923ebc90..7bdb85f76be98 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -41005,7 +41005,7 @@ static SDValue combineX86ShufflesRecursively(
     resolveTargetShuffleFromZeroables(OpMask, OpUndef, OpZero,
                                       ResolveKnownZeros);
 
-    Mask = OpMask;
+    Mask = std::move(OpMask);
     Ops.append(OpInputs.begin(), OpInputs.end());
   } else {
     resolveTargetShuffleFromZeroables(OpMask, OpUndef, OpZero);
diff --git a/llvm/utils/TableGen/SubtargetEmitter.cpp b/llvm/utils/TableGen/SubtargetEmitter.cpp
index c398b6f9bf7cd..aa5e56e15859b 100644
--- a/llvm/utils/TableGen/SubtargetEmitter.cpp
+++ b/llvm/utils/TableGen/SubtargetEmitter.cpp
@@ -1054,7 +1054,8 @@ void SubtargetEmitter::expandProcResources(
         continue;
       ConstRecVec SuperResources = PR->getValueAsListOfDefs("Resources");
       bool AllContained =
-          all_of(SubResources, [SuperResources](const Record *SubResource) {
+          all_of(SubResources, [SuperResources = std::move(SuperResources)](
+                                   const Record *SubResource) {
             return is_contained(SuperResources, SubResource);
           });
       if (AllContained) {

return matchUnaryPredicateImpl<ConstantSDNode>(Op, Match, AllowUndefs,
AllowTruncation);
return matchUnaryPredicateImpl<ConstantSDNode>(
Op, std::move(Match), AllowUndefs, AllowTruncation);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting - what warning / linter picked this up?

@@ -1054,7 +1054,8 @@ void SubtargetEmitter::expandProcResources(
continue;
ConstRecVec SuperResources = PR->getValueAsListOfDefs("Resources");
bool AllContained =
all_of(SubResources, [SuperResources](const Record *SubResource) {
all_of(SubResources, [SuperResources = std::move(SuperResources)](
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just [&SuperResources] ?

@kazutakahirata is there an STL version of this - something like is_all_contained(SuperResources,SubResources)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants