[lld] 39917b5 - [lld-macho] Don't sort map file entries by name

Jez Ng via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 25 13:29:24 PDT 2022


Author: Jez Ng
Date: 2022-10-25T16:29:13-04:00
New Revision: 39917b5e0174e0e4206df31da0e32b984c96c404

URL: https://github.com/llvm/llvm-project/commit/39917b5e0174e0e4206df31da0e32b984c96c404
DIFF: https://github.com/llvm/llvm-project/commit/39917b5e0174e0e4206df31da0e32b984c96c404.diff

LOG: [lld-macho] Don't sort map file entries by name

ld64 emits them in address order but not in alphabetical order. This
sorting is particularly expensive for dead-stripped symbols (which don't
need to be sorted at all, unlike live symbols that need to be sorted by
address).

Timings for chromium_framework_less_dwarf (with the `-map` flag added to
the response file) on my 16-core Mac Pro:

             base           diff           difference (95% CI)
  sys_time   1.997 ± 0.038  2.004 ± 0.028  [  -0.6% ..   +1.3%]
  user_time  8.698 ± 0.085  8.167 ± 0.070  [  -6.6% ..   -5.6%]
  wall_time  7.965 ± 0.114  7.715 ± 0.347  [  -5.1% ..   -1.2%]
  samples    25             23

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D136536

Added: 
    

Modified: 
    lld/MachO/MapFile.cpp
    lld/test/MachO/dead-strip.s

Removed: 
    


################################################################################
diff  --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp
index 0a8053cd7871a..8f1b6a13330a7 100644
--- a/lld/MachO/MapFile.cpp
+++ b/lld/MachO/MapFile.cpp
@@ -72,13 +72,7 @@ static MapInfo gatherMapInfo() {
         info.files.push_back(file);
     }
   parallelSort(info.liveSymbols.begin(), info.liveSymbols.end(),
-               [](Defined *a, Defined *b) {
-                 return a->getVA() != b->getVA() ? a->getVA() < b->getVA()
-                                                 : a->getName() < b->getName();
-               });
-  parallelSort(
-      info.deadSymbols.begin(), info.deadSymbols.end(),
-      [](Defined *a, Defined *b) { return a->getName() < b->getName(); });
+               [](Defined *a, Defined *b) { return a->getVA() < b->getVA(); });
   return info;
 }
 

diff  --git a/lld/test/MachO/dead-strip.s b/lld/test/MachO/dead-strip.s
index a9892fdd94b18..88b15382602f8 100644
--- a/lld/test/MachO/dead-strip.s
+++ b/lld/test/MachO/dead-strip.s
@@ -46,14 +46,14 @@
 ## Check that dead stripped symbols get listed properly.
 # RUN: FileCheck --check-prefix=MAP %s < %t/map
 
-# MAP: _main
+# MAP:        _main
 # MAP-LABEL: Dead Stripped Symbols
-# MAP: <<dead>> 0x00000001 [ 1] _unref_com
-# MAP: <<dead>> 0x00000008 [ 1] _unref_data
-# MAP: <<dead>> 0x00000006 [ 1] _unref_extern
-# MAP: <<dead>> 0x00000001 [ 1] _unref_local
-# MAP: <<dead>> 0x00000007 [ 1] _unref_private_extern
-# MAP: <<dead>> 0x00000008 [ 1] l_unref_data
+# MAP-DAG:   <<dead>> 0x00000001 [ 1] _unref_com
+# MAP-DAG:   <<dead>> 0x00000008 [ 1] _unref_data
+# MAP-DAG:   <<dead>> 0x00000006 [ 1] _unref_extern
+# MAP-DAG:   <<dead>> 0x00000001 [ 1] _unref_local
+# MAP-DAG:   <<dead>> 0x00000007 [ 1] _unref_private_extern
+# MAP-DAG:   <<dead>> 0x00000008 [ 1] l_unref_data
 
 ## Run dead stripping on code without any dead symbols.
 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos \


        


More information about the llvm-commits mailing list