[lld] 93558e5 - [ELF] Internalize createMergeSynthetic. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 16 20:50:11 PST 2021
Author: Fangrui Song
Date: 2021-12-16T20:50:06-08:00
New Revision: 93558e575e922e427cde242992569106de9fe256
URL: https://github.com/llvm/llvm-project/commit/93558e575e922e427cde242992569106de9fe256
DIFF: https://github.com/llvm/llvm-project/commit/93558e575e922e427cde242992569106de9fe256.diff
LOG: [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.
Added:
Modified:
lld/ELF/OutputSections.cpp
lld/ELF/SyntheticSections.cpp
lld/ELF/SyntheticSections.h
Removed:
################################################################################
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index a17f713b742a8..fc0b1ecef2b8c 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -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.
//
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 49b80772e5663..95d2cd5d65be8 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -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
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 3d2e73071d099..6fa99b6204db5 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -1182,8 +1182,6 @@ class PartitionIndexSection : public SyntheticSection {
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);
More information about the llvm-commits
mailing list