[ELF] Internalize createMergeSynthetic. NFC

Only called once. Moving to OutputSections.cpp can make it inlined.
finalizeInputSections can be very hot, especially in -O1 links with much debug info.
This commit is contained in:
Fangrui Song 2021-12-16 20:50:06 -08:00
parent 2444e305c5
commit 93558e575e
3 changed files with 9 additions and 11 deletions

View File

@ -155,6 +155,15 @@ void OutputSection::commitSection(InputSection *isec) {
entsize = 0;
}
static MergeSyntheticSection *createMergeSynthetic(StringRef name,
uint32_t type,
uint64_t flags,
uint32_t alignment) {
if ((flags & SHF_STRINGS) && config->optimize >= 2)
return make<MergeTailSection>(name, type, flags, alignment);
return make<MergeNoTailSection>(name, type, flags, alignment);
}
// This function scans over the InputSectionBase list sectionBases to create
// InputSectionDescription::sections.
//

View File

@ -3313,15 +3313,6 @@ void MergeNoTailSection::finalizeContents() {
});
}
MergeSyntheticSection *elf::createMergeSynthetic(StringRef name, uint32_t type,
uint64_t flags,
uint32_t alignment) {
bool shouldTailMerge = (flags & SHF_STRINGS) && config->optimize >= 2;
if (shouldTailMerge)
return make<MergeTailSection>(name, type, flags, alignment);
return make<MergeNoTailSection>(name, type, flags, alignment);
}
template <class ELFT> void elf::splitSections() {
llvm::TimeTraceScope timeScope("Split sections");
// splitIntoPieces needs to be called on each MergeInputSection

View File

@ -1182,8 +1182,6 @@ public:
InputSection *createInterpSection();
MergeInputSection *createCommentSection();
MergeSyntheticSection *createMergeSynthetic(StringRef name, uint32_t type,
uint64_t flags, uint32_t alignment);
template <class ELFT> void splitSections();
template <typename ELFT> void writeEhdr(uint8_t *buf, Partition &part);