summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Driver.cpp3
-rw-r--r--lld/ELF/InputSection.cpp4
-rw-r--r--lld/ELF/InputSection.h8
-rw-r--r--lld/ELF/MarkLive.cpp2
-rw-r--r--lld/ELF/SyntheticSections.cpp18
-rw-r--r--lld/ELF/SyntheticSections.h1
6 files changed, 13 insertions, 23 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index 208649faf83..2c29c518b4f 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -1303,9 +1303,10 @@ template <class ELFT> void LinkerDriver::link(opt::InputArgList &Args) {
// Do size optimizations: garbage collection, merging of SHF_MERGE sections
// and identical code folding.
+ decompressSections();
+ splitSections();
markLive<ELFT>();
demoteSymbols<ELFT>();
- decompressSections();
mergeSections();
if (Config->ICF)
doIcf<ELFT>();
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 871832a4ef7..7b64621a146 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -937,10 +937,6 @@ void MergeInputSection::splitIntoPieces() {
OffsetMap.reserve(Pieces.size());
for (size_t I = 0, E = Pieces.size(); I != E; ++I)
OffsetMap[Pieces[I].InputOff] = I;
-
- if (Config->GcSections && (Flags & SHF_ALLOC))
- for (uint32_t Off : LiveOffsets)
- getSectionPiece(Off)->Live = true;
}
template <class It, class T, class Compare>
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index 0a1954cdc2e..50ca557a634 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -223,12 +223,6 @@ public:
static bool classof(const SectionBase *S) { return S->kind() == Merge; }
void splitIntoPieces();
- // Mark the piece at a given offset live. Used by GC.
- void markLiveAt(uint64_t Offset) {
- if (this->Flags & llvm::ELF::SHF_ALLOC)
- LiveOffsets.insert(Offset);
- }
-
// Translate an offset in the input section to an offset in the parent
// MergeSyntheticSection.
uint64_t getParentOffset(uint64_t Offset) const;
@@ -259,8 +253,6 @@ public:
private:
void splitStrings(ArrayRef<uint8_t> A, size_t Size);
void splitNonStrings(ArrayRef<uint8_t> A, size_t Size);
-
- llvm::DenseSet<uint32_t> LiveOffsets;
};
struct EhSectionPiece {
diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp
index 6b80e8e77aa..d7cc74e48c1 100644
--- a/lld/ELF/MarkLive.cpp
+++ b/lld/ELF/MarkLive.cpp
@@ -207,7 +207,7 @@ template <class ELFT> static void doGcSections() {
// (splittable) sections, each piece of data has independent liveness bit.
// So we explicitly tell it which offset is in use.
if (auto *MS = dyn_cast<MergeInputSection>(Sec))
- MS->markLiveAt(Offset);
+ MS->getSectionPiece(Offset)->Live = true;
if (Sec->Live)
return;
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index ac16b858bc4..306bee478ac 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2536,9 +2536,16 @@ static MergeSyntheticSection *createMergeSynthetic(StringRef Name,
// Debug sections may be compressed by zlib. Decompress if exists.
void elf::decompressSections() {
+ parallelForEach(InputSections,
+ [](InputSectionBase *Sec) { Sec->maybeDecompress(); });
+}
+
+void elf::splitSections() {
+ // splitIntoPieces needs to be called on each MergeInputSection
+ // before calling finalizeContents().
parallelForEach(InputSections, [](InputSectionBase *Sec) {
- if (Sec->Live)
- Sec->maybeDecompress();
+ if (auto *S = dyn_cast<MergeInputSection>(Sec))
+ S->splitIntoPieces();
});
}
@@ -2550,13 +2557,6 @@ void elf::decompressSections() {
// 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 (auto *S = dyn_cast<MergeInputSection>(Sec))
- S->splitIntoPieces();
- });
-
std::vector<MergeSyntheticSection *> MergeSections;
for (InputSectionBase *&S : InputSections) {
MergeInputSection *MS = dyn_cast<MergeInputSection>(S);
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 49080e1601f..bd442a58262 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -834,6 +834,7 @@ private:
InputSection *createInterpSection();
MergeInputSection *createCommentSection();
void decompressSections();
+void splitSections();
void mergeSections();
Defined *addSyntheticLocal(StringRef Name, uint8_t Type, uint64_t Value,
OpenPOWER on IntegriCloud