[PATCH] D117273: [lld-macho] Simplify DeduplicatedCStringSection::finalizeContents. NFC
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 13 21:50:08 PST 2022
MaskRay created this revision.
MaskRay added a reviewer: lld-macho.
Herald added a project: lld-macho.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Tail merge is slow and of low value. With regular string deduplication, we can
just use the return value of StringTableBuilder::add.
I tried an ELF port style parallel algorithm, but did not see an improvement
when linking chromium_framework.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D117273
Files:
lld/MachO/SyntheticSections.cpp
Index: lld/MachO/SyntheticSections.cpp
===================================================================
--- lld/MachO/SyntheticSections.cpp
+++ lld/MachO/SyntheticSections.cpp
@@ -1379,26 +1379,15 @@
void DeduplicatedCStringSection::finalizeContents() {
// Add all string pieces to the string table builder to create section
// contents.
- for (const CStringInputSection *isec : inputs)
+ for (CStringInputSection *isec : inputs) {
for (size_t i = 0, e = isec->pieces.size(); i != e; ++i)
if (isec->pieces[i].live)
- builder.add(isec->getCachedHashStringRef(i));
+ isec->pieces[i].outSecOff =
+ builder.add(isec->getCachedHashStringRef(i));
+ isec->isFinal = true;
+ }
- // Fix the string table content. After this, the contents will never change.
builder.finalizeInOrder();
-
- // finalize() fixed tail-optimized strings, so we can now get
- // offsets of strings. Get an offset for each string and save it
- // to a corresponding SectionPiece for easy access.
- for (CStringInputSection *isec : inputs) {
- for (size_t i = 0, e = isec->pieces.size(); i != e; ++i) {
- if (!isec->pieces[i].live)
- continue;
- isec->pieces[i].outSecOff =
- builder.getOffset(isec->getCachedHashStringRef(i));
- isec->isFinal = true;
- }
- }
}
// This section is actually emitted as __TEXT,__const by ld64, but clang may
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D117273.399886.patch
Type: text/x-patch
Size: 1409 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220114/257ab451/attachment-0001.bin>
More information about the llvm-commits
mailing list