[PATCH] D134811: [lld-macho] Don't create entries in isecPriorities during sorting (NFC)
Daniel Bertalan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 28 07:37:29 PDT 2022
BertalanD created this revision.
BertalanD added a reviewer: lld-macho.
Herald added projects: lld-macho, All.
BertalanD requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If a value for a given key is not present, `DenseMap::operator[]`
default-constructs one, which is wasteful when we don't do anything with
it. Fix it by calling `lookup()` instead which only returns the default
value, but does not modify the map.
This speeds up linking a fair bit when only a small portion of all
sections are specified in the order file, like in the case of Chromium
Framework:
N Min Max Median Avg Stddev
x 25 3.727684 3.8808699 3.753552 3.7702461 0.0397282
+ 25 3.6469049 3.7523289 3.6764321 3.6841622 0.025525047
Difference at 95.0% confidence
-0.0860839 +/- 0.0189924
-2.28324% +/- 0.503745%
(Student's t, pooled s = 0.0333906)
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D134811
Files:
lld/MachO/Writer.cpp
Index: lld/MachO/Writer.cpp
===================================================================
--- lld/MachO/Writer.cpp
+++ lld/MachO/Writer.cpp
@@ -902,10 +902,10 @@
if (!isecPriorities.empty()) {
if (auto *merged = dyn_cast<ConcatOutputSection>(osec)) {
- llvm::stable_sort(merged->inputs,
- [&](InputSection *a, InputSection *b) {
- return isecPriorities[a] > isecPriorities[b];
- });
+ llvm::stable_sort(
+ merged->inputs, [&](InputSection *a, InputSection *b) {
+ return isecPriorities.lookup(a) > isecPriorities.lookup(b);
+ });
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134811.463559.patch
Type: text/x-patch
Size: 723 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220928/c57bd6d2/attachment.bin>
More information about the llvm-commits
mailing list