[lld] [lld] Use llvm::stable_sort (NFC) (PR #140488)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun May 18 19:02:22 PDT 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140488
None
>From 58e6465a3b39d0bad38ab04a5119f533ace365f2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 18 May 2025 18:43:55 -0700
Subject: [PATCH] [lld] Use llvm::stable_sort (NFC)
---
lld/COFF/LLDMapFile.cpp | 2 +-
lld/ELF/SyntheticSections.cpp | 7 +++----
lld/wasm/Writer.cpp | 24 ++++++++++++------------
3 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/lld/COFF/LLDMapFile.cpp b/lld/COFF/LLDMapFile.cpp
index 58098cf5d6528..49e9db905e370 100644
--- a/lld/COFF/LLDMapFile.cpp
+++ b/lld/COFF/LLDMapFile.cpp
@@ -65,7 +65,7 @@ static SymbolMapTy getSectionSyms(ArrayRef<DefinedRegular *> syms) {
// Sort symbols by address.
for (auto &it : ret) {
SmallVectorImpl<DefinedRegular *> &v = it.second;
- std::stable_sort(v.begin(), v.end(), [](DefinedRegular *a, DefinedRegular *b) {
+ llvm::stable_sort(v, [](DefinedRegular *a, DefinedRegular *b) {
return a->getRVA() < b->getRVA();
});
}
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 2531227cb99b7..46591e909ba4f 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -4677,10 +4677,9 @@ createMemtagGlobalDescriptors(Ctx &ctx,
bool MemtagGlobalDescriptors::updateAllocSize(Ctx &ctx) {
size_t oldSize = getSize();
- std::stable_sort(symbols.begin(), symbols.end(),
- [&ctx = ctx](const Symbol *s1, const Symbol *s2) {
- return s1->getVA(ctx) < s2->getVA(ctx);
- });
+ llvm::stable_sort(symbols, [&ctx = ctx](const Symbol *s1, const Symbol *s2) {
+ return s1->getVA(ctx) < s2->getVA(ctx);
+ });
return oldSize != getSize();
}
diff --git a/lld/wasm/Writer.cpp b/lld/wasm/Writer.cpp
index 3cc3e0d498979..21649bd15973c 100644
--- a/lld/wasm/Writer.cpp
+++ b/lld/wasm/Writer.cpp
@@ -1050,18 +1050,18 @@ void Writer::createOutputSegments() {
}
// Sort segments by type, placing .bss last
- std::stable_sort(segments.begin(), segments.end(),
- [](const OutputSegment *a, const OutputSegment *b) {
- auto order = [](StringRef name) {
- return StringSwitch<int>(name)
- .StartsWith(".tdata", 0)
- .StartsWith(".rodata", 1)
- .StartsWith(".data", 2)
- .StartsWith(".bss", 4)
- .Default(3);
- };
- return order(a->name) < order(b->name);
- });
+ llvm::stable_sort(segments,
+ [](const OutputSegment *a, const OutputSegment *b) {
+ auto order = [](StringRef name) {
+ return StringSwitch<int>(name)
+ .StartsWith(".tdata", 0)
+ .StartsWith(".rodata", 1)
+ .StartsWith(".data", 2)
+ .StartsWith(".bss", 4)
+ .Default(3);
+ };
+ return order(a->name) < order(b->name);
+ });
for (size_t i = 0; i < segments.size(); ++i)
segments[i]->index = i;
More information about the llvm-commits
mailing list