Skip to content

Commit 7c269db

Browse files
committed
[lld-macho] Simplify DeduplicatedCStringSection::finalizeContents. NFC
Tail merge is slow and of low value. With regular string deduplication, we can just use the return value of StringTableBuilder::add. There is no noticeable performance increase because without deduplication `__cstring` is quite small (7.6MiB for chromium_framework). Reviewed By: #lld-macho, Jez Ng Differential Revision: https://reviews.llvm.org/D117273
1 parent 6cacd42 commit 7c269db

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

lld/MachO/SyntheticSections.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,26 +1379,15 @@ DeduplicatedCStringSection::DeduplicatedCStringSection()
13791379
void DeduplicatedCStringSection::finalizeContents() {
13801380
// Add all string pieces to the string table builder to create section
13811381
// contents.
1382-
for (const CStringInputSection *isec : inputs)
1382+
for (CStringInputSection *isec : inputs) {
13831383
for (size_t i = 0, e = isec->pieces.size(); i != e; ++i)
13841384
if (isec->pieces[i].live)
1385-
builder.add(isec->getCachedHashStringRef(i));
1385+
isec->pieces[i].outSecOff =
1386+
builder.add(isec->getCachedHashStringRef(i));
1387+
isec->isFinal = true;
1388+
}
13861389

1387-
// Fix the string table content. After this, the contents will never change.
13881390
builder.finalizeInOrder();
1389-
1390-
// finalize() fixed tail-optimized strings, so we can now get
1391-
// offsets of strings. Get an offset for each string and save it
1392-
// to a corresponding SectionPiece for easy access.
1393-
for (CStringInputSection *isec : inputs) {
1394-
for (size_t i = 0, e = isec->pieces.size(); i != e; ++i) {
1395-
if (!isec->pieces[i].live)
1396-
continue;
1397-
isec->pieces[i].outSecOff =
1398-
builder.getOffset(isec->getCachedHashStringRef(i));
1399-
isec->isFinal = true;
1400-
}
1401-
}
14021391
}
14031392

14041393
// This section is actually emitted as __TEXT,__const by ld64, but clang may

0 commit comments

Comments
 (0)