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

via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 04:30:21 PST 2024


https://github.com/abhishek-kaushik22 updated https://github.com/llvm/llvm-project/pull/113080

>From 484f0cb80eb786f22bf0d926a966d7f6dba73f5f Mon Sep 17 00:00:00 2001
From: abhishek-kaushik22 <abhishek.kaushik at intel.com>
Date: Sun, 20 Oct 2024 16:04:04 +0530
Subject: [PATCH 1/2] Use `std::move` to avoid copy

---
 llvm/lib/CodeGen/MachineLICM.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 793ad75759ccb8..3b4f9ac5a63c4d 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -1377,7 +1377,7 @@ bool MachineLICMImpl::IsProfitableToHoist(MachineInstr &MI,
                }) &&
         IsLoopInvariantInst(MI, CurLoop) &&
         any_of(MRI->use_nodbg_instructions(DefReg),
-               [&CurLoop, this, DefReg, Cost](MachineInstr &UseMI) {
+               [&CurLoop, this, DefReg, std::move(Cost)](MachineInstr &UseMI) {
                  if (!CurLoop->contains(&UseMI))
                    return false;
 

>From efe9ab956b018f59d2d2a6144f4a5cae1285efc3 Mon Sep 17 00:00:00 2001
From: abhishek-kaushik22 <abhishek.kaushik at intel.com>
Date: Mon, 4 Nov 2024 18:00:09 +0530
Subject: [PATCH 2/2] Update MachineLICM.cpp

---
 llvm/lib/CodeGen/MachineLICM.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 3b4f9ac5a63c4d..34d531ba7a9fe9 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -1377,7 +1377,7 @@ bool MachineLICMImpl::IsProfitableToHoist(MachineInstr &MI,
                }) &&
         IsLoopInvariantInst(MI, CurLoop) &&
         any_of(MRI->use_nodbg_instructions(DefReg),
-               [&CurLoop, this, DefReg, std::move(Cost)](MachineInstr &UseMI) {
+               [&CurLoop, this, DefReg, Cost = std::move(Cost)](MachineInstr &UseMI) {
                  if (!CurLoop->contains(&UseMI))
                    return false;
 



More information about the llvm-commits mailing list