[lld] 9115d75 - [ELF] Use parallelSort for .rela.dyn

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 12 20:53:11 PST 2021


Author: Fangrui Song
Date: 2021-12-12T20:53:06-08:00
New Revision: 9115d75117b57115fe45153e5f38f2c444c0cd91

URL: https://github.com/llvm/llvm-project/commit/9115d75117b57115fe45153e5f38f2c444c0cd91
DIFF: https://github.com/llvm/llvm-project/commit/9115d75117b57115fe45153e5f38f2c444c0cd91.diff

LOG: [ELF] Use parallelSort for .rela.dyn

An unstable sort suffices. In a large link (11.06s), this decreases .rela.dyn
writeTo time from 1.52s to 0.81s, resulting in 6% total time speedup (the
benefit will greatly dilute if --pack-dyn-relocs=relr becomes prevailing).

Encoding the dynamic relocations then sorting raw Elf_Rel/Elf_Rela doesn't seem
to improve much (doing that would require code duplicate because of
Elf_Rel/Elf_Rela plus unfortunate mips64le), so don't do that.

Added: 
    

Modified: 
    lld/ELF/SyntheticSections.cpp

Removed: 
    


################################################################################
diff  --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 4078f7e01674..bcb521a47a4a 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -1678,7 +1678,7 @@ template <class ELFT> void RelocationSection<ELFT>::writeTo(uint8_t *buf) {
   // place R_*_RELATIVE first. SymIndex is to improve locality, while r_offset
   // is to make results easier to read.
   if (sort)
-    llvm::stable_sort(
+    parallelSort(
         relocs, [&](const DynamicReloc &a, const DynamicReloc &b) {
           return std::make_tuple(a.type != target->relativeRel,
                                  a.getSymIndex(symTab), a.getOffset()) <


        


More information about the llvm-commits mailing list