[llvm] [perf] Replace extra copy-assign by move-assign in llvm/lib/ (PR #179465)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 06:20:08 PST 2026


https://github.com/serge-sans-paille updated https://github.com/llvm/llvm-project/pull/179465

>From 52e03a036a6e5c181c0d8fae9f00a780497ae2f1 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Tue, 3 Feb 2026 14:57:51 +0100
Subject: [PATCH 1/2] [perf] Replace extra copy-assign by move-assign in
 llvm/lib/

---
 llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 2 +-
 llvm/lib/Support/VirtualFileSystem.cpp                 | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 6dda0fddbcec8..7754f5ed079bf 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -446,7 +446,7 @@ class TransferTracker {
     auto NewValue = ResolvedDbgValue{ResolvedDbgOps, Value.Properties};
     auto Result = ActiveVLocs.insert(std::make_pair(VarID, NewValue));
     if (!Result.second)
-      Result.first->second = NewValue;
+      Result.first->second = std::move(NewValue);
   }
 
   /// Load object with live-in variable values. \p mlocs contains the live-in
diff --git a/llvm/lib/Support/VirtualFileSystem.cpp b/llvm/lib/Support/VirtualFileSystem.cpp
index 49a5cefe6a7d7..8a7ca35a8dd25 100644
--- a/llvm/lib/Support/VirtualFileSystem.cpp
+++ b/llvm/lib/Support/VirtualFileSystem.cpp
@@ -278,7 +278,7 @@ class RealFileSystem : public FileSystem {
     if (!LinkCWDToProcess) {
       SmallString<128> PWD, RealPWD;
       if (std::error_code EC = llvm::sys::fs::current_path(PWD))
-        WD = EC;
+        WD = std::move(EC);
       else if (llvm::sys::fs::real_path(PWD, RealPWD))
         WD = WorkingDirectory{PWD, PWD};
       else

>From 51b99f3394f10576ffa7755c5cbb36703a3e15a1 Mon Sep 17 00:00:00 2001
From: serge-sans-paille <sguelton at mozilla.com>
Date: Tue, 3 Feb 2026 15:19:49 +0100
Subject: [PATCH 2/2] fixup! [perf] Replace extra copy-assign by move-assign in
 llvm/lib/

---
 llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
index 7754f5ed079bf..293869774912e 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp
@@ -444,9 +444,7 @@ class TransferTracker {
       if (!Op.IsConst)
         ActiveMLocs[Op.Loc].insert(VarID);
     auto NewValue = ResolvedDbgValue{ResolvedDbgOps, Value.Properties};
-    auto Result = ActiveVLocs.insert(std::make_pair(VarID, NewValue));
-    if (!Result.second)
-      Result.first->second = std::move(NewValue);
+    ActiveVLocs.insert_or_assign(std::make_pair(VarID, std::move(NewValue)));
   }
 
   /// Load object with live-in variable values. \p mlocs contains the live-in



More information about the llvm-commits mailing list