[lld] 0cd8fd9 - [lld] Add explicit std::move(...) to avoid a few vector copies (#180474)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 9 03:59:09 PST 2026
Author: serge-sans-paille
Date: 2026-02-09T11:59:04Z
New Revision: 0cd8fd974dd674cab2f53cedeb674622413561bd
URL: https://github.com/llvm/llvm-project/commit/0cd8fd974dd674cab2f53cedeb674622413561bd
DIFF: https://github.com/llvm/llvm-project/commit/0cd8fd974dd674cab2f53cedeb674622413561bd.diff
LOG: [lld] Add explicit std::move(...) to avoid a few vector copies (#180474)
In corner cases, it is profitable to move an llvm::SmallString instead
of copying it.
It is almost always profitable to move an std::vector
Changes suggested by performance-use-std-move from
https://github.com/llvm/llvm-project/pull/179467
Added:
Modified:
lld/COFF/Driver.cpp
lld/wasm/OutputSections.cpp
lld/wasm/Writer.cpp
Removed:
################################################################################
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index 3bc9c98bcdbc3..699d53ca6d2e3 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -1339,7 +1339,7 @@ void LinkerDriver::parsePDBAltPath() {
cursor = secondMark + 1;
}
- ctx.config.pdbAltPath = buf;
+ ctx.config.pdbAltPath = std::move(buf);
}
/// Convert resource files and potentially merge input resource object
diff --git a/lld/wasm/OutputSections.cpp b/lld/wasm/OutputSections.cpp
index 8ccd38f7895cb..d6348e459d31e 100644
--- a/lld/wasm/OutputSections.cpp
+++ b/lld/wasm/OutputSections.cpp
@@ -232,7 +232,7 @@ void CustomSection::finalizeInputSections() {
return;
mergedSection->finalizeContents();
- inputSections = newSections;
+ inputSections = std::move(newSections);
}
void CustomSection::finalizeContents() {
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index a184cdbdfefa8..40a5832056087 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -1109,7 +1109,7 @@ void Writer::combineOutputSegments() {
}
}
- segments = newSegments;
+ segments = std::move(newSegments);
}
static void createFunction(DefinedFunction *func, StringRef bodyContent) {
More information about the llvm-commits
mailing list