[lld] r261711 - ELF: Remove InputSectionBase::isLive and use Live member instead. NFC.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 23 16:23:15 PST 2016
Author: ruiu
Date: Tue Feb 23 18:23:15 2016
New Revision: 261711
URL: http://llvm.org/viewvc/llvm-project?rev=261711&view=rev
Log:
ELF: Remove InputSectionBase::isLive and use Live member instead. NFC.
This is also a preparation for ICF.
Modified:
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/OutputSections.cpp
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=261711&r1=261710&r2=261711&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Tue Feb 23 18:23:15 2016
@@ -25,7 +25,13 @@ template <class ELFT>
InputSectionBase<ELFT>::InputSectionBase(ObjectFile<ELFT> *File,
const Elf_Shdr *Header,
Kind SectionKind)
- : Header(Header), File(File), SectionKind(SectionKind) {}
+ : Header(Header), File(File), SectionKind(SectionKind) {
+ // The garbage collector sets sections' Live bits.
+ // If GC is disabled, all sections are considered live by default.
+ // NB: "Discarded" section is initialized at start-up and when it
+ // happens Config is still null.
+ Live = Config && !Config->GcSections;
+}
template <class ELFT> StringRef InputSectionBase<ELFT>::getSectionName() const {
ErrorOr<StringRef> Name = File->getObj().getSectionName(this->Header);
Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=261711&r1=261710&r2=261711&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Tue Feb 23 18:23:15 2016
@@ -44,8 +44,6 @@ public:
OutputSectionBase<ELFT> *OutSec = nullptr;
// Used for garbage collection.
- // Live bit makes sense only when Config->GcSections is true.
- bool isLive() const { return !Config->GcSections || Live; }
bool Live = false;
// Returns the size of this section (even if this is a common or BSS.)
Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=261711&r1=261710&r2=261711&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Tue Feb 23 18:23:15 2016
@@ -885,7 +885,7 @@ elf2::getLocalRelTarget(const ObjectFile
// the group are not allowed. Unfortunately .eh_frame breaks that rule
// and must be treated specially. For now we just replace the symbol with
// 0.
- if (Section == &InputSection<ELFT>::Discarded || !Section->isLive())
+ if (Section == &InputSection<ELFT>::Discarded || !Section->Live)
return Addend;
uintX_t Offset = Sym->st_value;
@@ -1148,7 +1148,7 @@ void EHOutputSection<ELFT>::addSectionAu
if (!HasReloc)
fatal("FDE doesn't reference another section");
InputSectionBase<ELFT> *Target = S->getRelocTarget(*RelI);
- if (Target != &InputSection<ELFT>::Discarded && Target->isLive()) {
+ if (Target != &InputSection<ELFT>::Discarded && Target->Live) {
uint32_t CieOffset = Offset + 4 - ID;
auto I = OffsetToIndex.find(CieOffset);
if (I == OffsetToIndex.end())
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=261711&r1=261710&r2=261711&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Feb 23 18:23:15 2016
@@ -549,7 +549,7 @@ template <class ELFT> void Writer<ELFT>:
continue;
if (Sym.st_shndx != SHN_ABS) {
InputSectionBase<ELFT> *Section = F->getSection(Sym);
- if (!Section->isLive())
+ if (!Section->Live)
continue;
}
++Out<ELFT>::SymTab->NumLocals;
@@ -744,7 +744,7 @@ StringRef Writer<ELFT>::getOutputSection
template <class ELFT>
void reportDiscarded(InputSectionBase<ELFT> *IS,
const std::unique_ptr<ObjectFile<ELFT>> &File) {
- if (!Config->PrintGcSections || !IS || IS->isLive())
+ if (!Config->PrintGcSections || !IS || IS->Live)
return;
llvm::errs() << "removing unused section from '" << IS->getSectionName()
<< "' in file '" << File->getName() << "'\n";
@@ -752,7 +752,7 @@ void reportDiscarded(InputSectionBase<EL
template <class ELFT>
bool Writer<ELFT>::isDiscarded(InputSectionBase<ELFT> *S) const {
- return !S || !S->isLive() || S == &InputSection<ELFT>::Discarded ||
+ return !S || !S->Live || S == &InputSection<ELFT>::Discarded ||
Script->isDiscarded(S);
}
@@ -786,7 +786,7 @@ template <class ELFT> static bool includ
if (&D->Sym == &ElfSym<ELFT>::Ignored)
return false;
// Exclude symbols pointing to garbage-collected sections.
- if (D->Section && !D->Section->isLive())
+ if (D->Section && !D->Section->Live)
return false;
}
return true;
More information about the llvm-commits
mailing list