From 484f0cb80eb786f22bf0d926a966d7f6dba73f5f Mon Sep 17 00:00:00 2001 From: abhishek-kaushik22 Date: Sun, 20 Oct 2024 16:04:04 +0530 Subject: [PATCH 1/4] 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 793ad75759ccb..3b4f9ac5a63c4 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 Date: Mon, 4 Nov 2024 18:00:09 +0530 Subject: [PATCH 2/4] 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 3b4f9ac5a63c4..34d531ba7a9fe 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; From a87d3786ca744613129317921135126d828f24fc Mon Sep 17 00:00:00 2001 From: abhishek-kaushik22 Date: Mon, 4 Nov 2024 18:04:31 +0530 Subject: [PATCH 3/4] Update MachineLICM.cpp --- llvm/lib/CodeGen/MachineLICM.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp index 34d531ba7a9fe..d66aa7c14da7e 100644 --- a/llvm/lib/CodeGen/MachineLICM.cpp +++ b/llvm/lib/CodeGen/MachineLICM.cpp @@ -1377,7 +1377,8 @@ bool MachineLICMImpl::IsProfitableToHoist(MachineInstr &MI, }) && IsLoopInvariantInst(MI, CurLoop) && any_of(MRI->use_nodbg_instructions(DefReg), - [&CurLoop, this, DefReg, Cost = std::move(Cost)](MachineInstr &UseMI) { + [&CurLoop, this, DefReg, + Cost = std::move(Cost)](MachineInstr &UseMI) { if (!CurLoop->contains(&UseMI)) return false; From 106fba7343cbc3ba1b7cca6847d72210dc0ffa82 Mon Sep 17 00:00:00 2001 From: abhishek-kaushik22 Date: Mon, 4 Nov 2024 18:13:23 +0530 Subject: [PATCH 4/4] 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 d66aa7c14da7e..dfac103f6a4a4 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, + [&CurLoop, this, DefReg, Cost = std::move(Cost)](MachineInstr &UseMI) { if (!CurLoop->contains(&UseMI)) return false;