[lld] r315422 - Split decompressAndMergeSection into two separate functions.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 20:12:53 PDT 2017
Author: ruiu
Date: Tue Oct 10 20:12:53 2017
New Revision: 315422
URL: http://llvm.org/viewvc/llvm-project?rev=315422&view=rev
Log:
Split decompressAndMergeSection into two separate functions.
Even though they are called sequentially, they are separate
operations, so it is better to split it.
Modified:
lld/trunk/ELF/Driver.cpp
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=315422&r1=315421&r2=315422&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Oct 10 20:12:53 2017
@@ -1107,7 +1107,8 @@ template <class ELFT> void LinkerDriver:
// Do size optimizations: garbage collection, merging of SHF_MERGE sections
// and identical code folding.
markLive<ELFT>();
- decompressAndMergeSections();
+ decompressSections();
+ mergeSections();
if (Config->ICF)
doIcf<ELFT>();
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=315422&r1=315421&r2=315422&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Oct 10 20:12:53 2017
@@ -196,10 +196,7 @@ OutputSection *SectionBase::getOutputSec
// Uncompress section contents if required. Note that this function
// is called from parallelForEach, so it must be thread-safe.
void InputSectionBase::maybeUncompress() {
- if (UncompressBuf)
- return;
-
- if (!Decompressor::isCompressedELFSection(Flags, Name))
+ if (UncompressBuf || !Decompressor::isCompressedELFSection(Flags, Name))
return;
Decompressor Dec = check(Decompressor::create(Name, toStringRef(Data),
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=315422&r1=315421&r2=315422&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Oct 10 20:12:53 2017
@@ -2305,21 +2305,28 @@ static MergeSyntheticSection *createMerg
return make<MergeNoTailSection>(Name, Type, Flags, Alignment);
}
-// This function decompresses compressed sections and scans over the input
-// sections to create mergeable synthetic sections. It removes
-// MergeInputSections from the input section array and adds new synthetic
-// sections at the location of the first input section that it replaces. It then
-// finalizes each synthetic section in order to compute an output offset for
-// each piece of each input section.
-void elf::decompressAndMergeSections() {
- // splitIntoPieces needs to be called on each MergeInputSection before calling
- // finalizeContents(). Do that first.
- parallelForEach(InputSections, [](InputSectionBase *S) {
- if (!S->Live)
- return;
- S->maybeUncompress();
- if (auto *MS = dyn_cast<MergeInputSection>(S))
- MS->splitIntoPieces();
+// Debug sections may be compressed by zlib. Uncompress if exists.
+void elf::decompressSections() {
+ parallelForEach(InputSections, [](InputSectionBase *Sec) {
+ if (Sec->Live)
+ Sec->maybeUncompress();
+ });
+}
+
+// This function scans over the inputsections to create mergeable
+// synthetic sections.
+//
+// It removes MergeInputSections from the input section array and adds
+// new synthetic sections at the location of the first input section
+// that it replaces. It then finalizes each synthetic section in order
+// to compute an output offset for each piece of each input section.
+void elf::mergeSections() {
+ // splitIntoPieces needs to be called on each MergeInputSection
+ // before calling finalizeContents(). Do that first.
+ parallelForEach(InputSections, [](InputSectionBase *Sec) {
+ if (Sec->Live)
+ if (auto *S = dyn_cast<MergeInputSection>(Sec))
+ S->splitIntoPieces();
});
std::vector<MergeSyntheticSection *> MergeSections;
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=315422&r1=315421&r2=315422&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Tue Oct 10 20:12:53 2017
@@ -805,7 +805,8 @@ private:
template <class ELFT> void createCommonSections();
InputSection *createInterpSection();
template <class ELFT> MergeInputSection *createCommentSection();
-void decompressAndMergeSections();
+void decompressSections();
+void mergeSections();
SymbolBody *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
uint64_t Size, InputSectionBase *Section);
More information about the llvm-commits
mailing list