[lld] f855074 - [ELF] GnuHashTableSection: replace stable_sort with 2-key sort. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 17 00:34:47 PST 2022
Author: Fangrui Song
Date: 2022-01-17T00:34:42-08:00
New Revision: f855074ed1193d5fd96b02280c31479294ce0901
URL: https://github.com/llvm/llvm-project/commit/f855074ed1193d5fd96b02280c31479294ce0901
DIFF: https://github.com/llvm/llvm-project/commit/f855074ed1193d5fd96b02280c31479294ce0901.diff
LOG: [ELF] GnuHashTableSection: replace stable_sort with 2-key sort. NFC
strTabOffset stabilizes llvm::sort. My x86-64 executable is 5+KiB smaller.
Added:
Modified:
lld/ELF/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index f20000ab7a3b..3e6773545142 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2478,8 +2478,9 @@ void GnuHashTableSection::addSymbols(SmallVectorImpl<SymbolTableEntry> &v) {
symbols.push_back({b, ent.strTabOffset, hash, bucketIdx});
}
- llvm::stable_sort(symbols, [](const Entry &l, const Entry &r) {
- return l.bucketIdx < r.bucketIdx;
+ llvm::sort(symbols, [](const Entry &l, const Entry &r) {
+ return std::tie(l.bucketIdx, l.strTabOffset) <
+ std::tie(r.bucketIdx, r.strTabOffset);
});
v.erase(mid, v.end());
More information about the llvm-commits
mailing list