[llvm] [RegAlloc][NFC] Use `std::move` to avoid copy (PR #134533)

Abhishek Kaushik via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 6 04:21:35 PDT 2025


https://github.com/abhishek-kaushik22 created https://github.com/llvm/llvm-project/pull/134533

None

>From 2bd2335ba3f08054c019abf82bc25983d7ffacf1 Mon Sep 17 00:00:00 2001
From: abhishek-kaushik22 <abhishek.kaushik at intel.com>
Date: Sun, 6 Apr 2025 16:50:53 +0530
Subject: [PATCH] [RegAlloc][NFC] Use `std::move` to  avoid copy

---
 llvm/include/llvm/CodeGen/RegAllocFast.h       | 4 ++--
 llvm/include/llvm/CodeGen/RegAllocGreedyPass.h | 4 ++--
 llvm/lib/CodeGen/RegAllocGreedy.cpp            | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/RegAllocFast.h b/llvm/include/llvm/CodeGen/RegAllocFast.h
index 9fdaca09e4317..83b9125dc07e9 100644
--- a/llvm/include/llvm/CodeGen/RegAllocFast.h
+++ b/llvm/include/llvm/CodeGen/RegAllocFast.h
@@ -22,10 +22,10 @@ class RegAllocFastPass : public PassInfoMixin<RegAllocFastPass> {
     bool ClearVRegs;
     Options(RegAllocFilterFunc F = nullptr, StringRef FN = "all",
             bool CV = true)
-        : Filter(F), FilterName(FN), ClearVRegs(CV) {}
+        : Filter(std::move(F)), FilterName(FN), ClearVRegs(CV) {}
   };
 
-  RegAllocFastPass(Options Opts = Options()) : Opts(Opts) {}
+  RegAllocFastPass(Options Opts = Options()) : Opts(std::move(Opts)) {}
 
   MachineFunctionProperties getRequiredProperties() const {
     return MachineFunctionProperties().set(
diff --git a/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h b/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
index 1281ca851f069..d2fd66f8da593 100644
--- a/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
+++ b/llvm/include/llvm/CodeGen/RegAllocGreedyPass.h
@@ -21,10 +21,10 @@ class RAGreedyPass : public PassInfoMixin<RAGreedyPass> {
     RegAllocFilterFunc Filter;
     StringRef FilterName;
     Options(RegAllocFilterFunc F = nullptr, StringRef FN = "all")
-        : Filter(F), FilterName(FN) {};
+        : Filter(std::move(F)), FilterName(FN) {};
   };
 
-  RAGreedyPass(Options Opts = Options()) : Opts(Opts) {}
+  RAGreedyPass(Options Opts = Options()) : Opts(std::move(Opts)) {}
   PreservedAnalyses run(MachineFunction &F, MachineFunctionAnalysisManager &AM);
 
   MachineFunctionProperties getRequiredProperties() const {
diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp
index a5cd9fc7a5360..56d3bd953f57d 100644
--- a/llvm/lib/CodeGen/RegAllocGreedy.cpp
+++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp
@@ -179,7 +179,7 @@ class RAGreedyLegacy : public MachineFunctionPass {
 } // end anonymous namespace
 
 RAGreedyLegacy::RAGreedyLegacy(const RegAllocFilterFunc F)
-    : MachineFunctionPass(ID), F(F) {
+    : MachineFunctionPass(ID), F(std::move(F)) {
   initializeRAGreedyLegacyPass(*PassRegistry::getPassRegistry());
 }
 



More information about the llvm-commits mailing list