diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2016-10-26 12:36:56 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2016-10-26 12:36:56 +0000 |
| commit | 1854a8ebb83954c9969ac49cc2ababfdd0223520 (patch) | |
| tree | ab7c275ad8e368787fb0c2d873a850baa6800709 | |
| parent | 3c9899842bf4d0a69a6346026f60f070ac92016b (diff) | |
| download | bcm5719-llvm-1854a8ebb83954c9969ac49cc2ababfdd0223520.tar.gz bcm5719-llvm-1854a8ebb83954c9969ac49cc2ababfdd0223520.zip | |
Delete trivial getters. NFC.
llvm-svn: 285190
| -rw-r--r-- | lld/ELF/ICF.cpp | 6 | ||||
| -rw-r--r-- | lld/ELF/InputSection.cpp | 28 | ||||
| -rw-r--r-- | lld/ELF/InputSection.h | 9 | ||||
| -rw-r--r-- | lld/ELF/LinkerScript.cpp | 6 | ||||
| -rw-r--r-- | lld/ELF/MarkLive.cpp | 8 | ||||
| -rw-r--r-- | lld/ELF/OutputSections.cpp | 17 | ||||
| -rw-r--r-- | lld/ELF/Relocations.cpp | 4 | ||||
| -rw-r--r-- | lld/ELF/Writer.cpp | 4 |
8 files changed, 38 insertions, 44 deletions
diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index df4f763aa8f..913902c203b 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -119,7 +119,7 @@ private: // Returns a hash value for S. Note that the information about // relocation targets is not included in the hash value. template <class ELFT> uint64_t ICF<ELFT>::getHash(InputSection<ELFT> *S) { - uint64_t Flags = S->getFlags(); + uint64_t Flags = S->Flags; uint64_t H = hash_combine(Flags, S->getSize()); for (const Elf_Shdr *Rel : S->RelocSections) H = hash_combine(H, (uint64_t)Rel->sh_size); @@ -141,7 +141,7 @@ template <class ELFT> bool ICF<ELFT>::isEligible(InputSectionBase<ELFT> *Sec) { if (Name == ".init" || Name == ".fini") return false; - return (S->getFlags() & SHF_ALLOC) && !(S->getFlags() & SHF_WRITE); + return (S->Flags & SHF_ALLOC) && !(S->Flags & SHF_WRITE); } template <class ELFT> @@ -230,7 +230,7 @@ bool ICF<ELFT>::equalsConstant(const InputSection<ELFT> *A, } } - return A->getFlags() == B->getFlags() && A->getSize() == B->getSize() && + return A->Flags == B->Flags && A->getSize() == B->getSize() && A->Data == B->Data; } diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp index d407be4068b..506246fa140 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -161,7 +161,7 @@ template <class ELFT> void InputSectionBase<ELFT>::uncompress() { // shouldn't be significant in ELF.) We need to be able to read both. ArrayRef<uint8_t> Buf; // Compressed data size_t Size; // Uncompressed size - if (getFlags() & SHF_COMPRESSED) + if (Flags & SHF_COMPRESSED) std::tie(Buf, Size) = getElfCompressedData(Data); else std::tie(Buf, Size) = getRawCompressedData(Data); @@ -182,8 +182,8 @@ InputSectionBase<ELFT>::getOffset(const DefinedRegular<ELFT> &Sym) const { template <class ELFT> InputSectionBase<ELFT> *InputSectionBase<ELFT>::getLinkOrderDep() const { - if ((getFlags() & SHF_LINK_ORDER) && getLink() != 0) - return getFile()->getSections()[getLink()]; + if ((Flags & SHF_LINK_ORDER) && Link != 0) + return getFile()->getSections()[Link]; return nullptr; } @@ -206,9 +206,9 @@ bool InputSection<ELFT>::classof(const InputSectionBase<ELFT> *S) { template <class ELFT> InputSectionBase<ELFT> *InputSection<ELFT>::getRelocatedSection() { - assert(this->getType() == SHT_RELA || this->getType() == SHT_REL); + assert(this->Type == SHT_RELA || this->Type == SHT_REL); ArrayRef<InputSectionBase<ELFT> *> Sections = this->File->getSections(); - return Sections[this->getInfo()]; + return Sections[this->Info]; } template <class ELFT> void InputSection<ELFT>::addThunk(const Thunk<ELFT> *T) { @@ -418,7 +418,7 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd) { // vector only for SHF_ALLOC'ed sections. For other sections, // we handle relocations directly here. auto *IS = dyn_cast<InputSection<ELFT>>(this); - if (IS && !(IS->getFlags() & SHF_ALLOC)) { + if (IS && !(IS->Flags & SHF_ALLOC)) { for (const Elf_Shdr *RelSec : IS->RelocSections) { if (RelSec->sh_type == SHT_RELA) IS->relocateNonAlloc(Buf, IS->File->getObj().relas(RelSec)); @@ -474,15 +474,15 @@ void InputSectionBase<ELFT>::relocate(uint8_t *Buf, uint8_t *BufEnd) { } template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) { - if (this->getType() == SHT_NOBITS) + if (this->Type == SHT_NOBITS) return; // If -r is given, then an InputSection may be a relocation section. - if (this->getType() == SHT_RELA) { + if (this->Type == SHT_RELA) { copyRelocations(Buf + OutSecOff, this->template getDataAs<Elf_Rela>()); return; } - if (this->getType() == SHT_REL) { + if (this->Type == SHT_REL) { copyRelocations(Buf + OutSecOff, this->template getDataAs<Elf_Rel>()); return; } @@ -605,7 +605,7 @@ std::vector<SectionPiece> MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data, size_t EntSize) { std::vector<SectionPiece> V; size_t Off = 0; - bool IsAlloca = this->getFlags() & SHF_ALLOC; + bool IsAlloca = this->Flags & SHF_ALLOC; while (!Data.empty()) { size_t End = findNull(Data, EntSize); if (End == StringRef::npos) @@ -636,7 +636,7 @@ MergeInputSection<ELFT>::splitNonStrings(ArrayRef<uint8_t> Data, std::vector<SectionPiece> V; size_t Size = Data.size(); assert((Size % EntSize) == 0); - bool IsAlloca = this->getFlags() & SHF_ALLOC; + bool IsAlloca = this->Flags & SHF_ALLOC; for (unsigned I = 0, N = Size; I != N; I += EntSize) { Hashes.push_back(hash_value(toStringRef(Data.slice(I, EntSize)))); V.emplace_back(I, !IsAlloca); @@ -652,13 +652,13 @@ MergeInputSection<ELFT>::MergeInputSection(elf::ObjectFile<ELFT> *F, template <class ELFT> void MergeInputSection<ELFT>::splitIntoPieces() { ArrayRef<uint8_t> Data = this->Data; - uintX_t EntSize = this->getEntsize(); - if (this->getFlags() & SHF_STRINGS) + uintX_t EntSize = this->Entsize; + if (this->Flags & SHF_STRINGS) this->Pieces = splitStrings(Data, EntSize); else this->Pieces = splitNonStrings(Data, EntSize); - if (Config->GcSections && (this->getFlags() & SHF_ALLOC)) + if (Config->GcSections && (this->Flags & SHF_ALLOC)) for (uintX_t Off : LiveOffsets) this->getSectionPiece(Off)->Live = true; } diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h index 40ae21eeb8e..cd181924aa4 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -85,6 +85,7 @@ protected: // The file this section is from. ObjectFile<ELFT> *File; +public: // These corresponds to the fields in Elf_Shdr. uintX_t Flags; uintX_t Entsize; @@ -92,7 +93,6 @@ protected: uint32_t Link; uint32_t Info; -public: InputSectionBase() : InputSectionData(Regular, "", ArrayRef<uint8_t>(), false, false), Repl(this) {} @@ -117,11 +117,6 @@ public: static InputSectionBase<ELFT> Discarded; - uintX_t getFlags() const { return Flags; } - uint32_t getType() const { return Type; } - uintX_t getEntsize() const { return Entsize; } - uint32_t getLink() const { return Link; } - uint32_t getInfo() const { return Info; } ObjectFile<ELFT> *getFile() const { return File; } uintX_t getOffset(const DefinedRegular<ELFT> &Sym) const; InputSectionBase *getLinkOrderDep() const; @@ -172,7 +167,7 @@ public: // Mark the piece at a given offset live. Used by GC. void markLiveAt(uintX_t Offset) { - assert(this->getFlags() & llvm::ELF::SHF_ALLOC); + assert(this->Flags & llvm::ELF::SHF_ALLOC); LiveOffsets.insert(Offset); } diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index ed6dd69989a..3b835d929d2 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -156,7 +156,7 @@ static bool matchConstraints(ArrayRef<InputSectionBase<ELFT> *> Sections, return true; bool IsRW = llvm::any_of(Sections, [=](InputSectionData *Sec2) { auto *Sec = static_cast<InputSectionBase<ELFT> *>(Sec2); - return Sec->getFlags() & SHF_WRITE; + return Sec->Flags & SHF_WRITE; }); return (IsRW && Kind == ConstraintKind::ReadWrite) || (!IsRW && Kind == ConstraintKind::ReadOnly); @@ -269,11 +269,11 @@ static SectionKey<ELFT::Is64Bits> createKey(InputSectionBase<ELFT> *C, // supported by bfd or gold, so we can just create multiple section in that // case. typedef typename ELFT::uint uintX_t; - uintX_t Flags = C->getFlags() & (SHF_MERGE | SHF_STRINGS); + uintX_t Flags = C->Flags & (SHF_MERGE | SHF_STRINGS); uintX_t Alignment = 0; if (isa<MergeInputSection<ELFT>>(C)) - Alignment = std::max<uintX_t>(C->Alignment, C->getEntsize()); + Alignment = std::max<uintX_t>(C->Alignment, C->Entsize); return SectionKey<ELFT::Is64Bits>{OutsecName, /*Type*/ 0, Flags, Alignment}; } diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index 4502d9decb0..dca1be74ad6 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -135,7 +135,7 @@ scanEhFrameSection(EhInputSection<ELFT> &EH, ArrayRef<RelTy> Rels, ResolvedReloc<ELFT> R = resolveReloc(EH, Rels[I2]); if (!R.Sec || R.Sec == &InputSection<ELFT>::Discarded) continue; - if (R.Sec->getFlags() & SHF_EXECINSTR) + if (R.Sec->Flags & SHF_EXECINSTR) continue; Enqueue({R.Sec, 0}); } @@ -164,14 +164,14 @@ scanEhFrameSection(EhInputSection<ELFT> &EH, // 1) Sections used by the loader (.init, .fini, .ctors, .dtors or .jcr) // 2) Non-allocatable sections which typically contain debugging information template <class ELFT> static bool isReserved(InputSectionBase<ELFT> *Sec) { - switch (Sec->getType()) { + switch (Sec->Type) { case SHT_FINI_ARRAY: case SHT_INIT_ARRAY: case SHT_NOTE: case SHT_PREINIT_ARRAY: return true; default: - if (!(Sec->getFlags() & SHF_ALLOC)) + if (!(Sec->Flags & SHF_ALLOC)) return true; // We do not want to reclaim sections if they can be referred @@ -201,7 +201,7 @@ template <class ELFT> void elf::markLive() { return; // We don't gc non alloc sections. - if (!(R.Sec->getFlags() & SHF_ALLOC)) + if (!(R.Sec->Flags & SHF_ALLOC)) return; // Usually, a whole section is marked as live or dead, but in mergeable diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp index 0bbd4ed033f..5566a422537 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -966,8 +966,8 @@ void OutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) { this->updateAlignment(S->Alignment); // Keep sh_entsize value of the input section to be able to perform merging // later during a final linking using the generated relocatable object. - if (Config->Relocatable && (S->getFlags() & SHF_MERGE)) - this->Header.sh_entsize = S->getEntsize(); + if (Config->Relocatable && (S->Flags & SHF_MERGE)) + this->Header.sh_entsize = S->Entsize; } // This function is called after we sort input sections @@ -1304,7 +1304,7 @@ void MergeOutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) { auto *Sec = cast<MergeInputSection<ELFT>>(C); Sec->OutSec = this; this->updateAlignment(Sec->Alignment); - this->Header.sh_entsize = Sec->getEntsize(); + this->Header.sh_entsize = Sec->Entsize; Sections.push_back(Sec); auto HashI = Sec->Hashes.begin(); @@ -1896,7 +1896,7 @@ void MipsAbiFlagsOutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) { template <class ELFT> static typename ELFT::uint getOutFlags(InputSectionBase<ELFT> *S) { - return S->getFlags() & ~SHF_GROUP & ~SHF_COMPRESSED; + return S->Flags & ~SHF_GROUP & ~SHF_COMPRESSED; } template <class ELFT> @@ -1913,11 +1913,10 @@ static SectionKey<ELFT::Is64Bits> createKey(InputSectionBase<ELFT> *C, // output sections for them to allow merging at final linking stage. uintX_t Alignment = 0; if (isa<MergeInputSection<ELFT>>(C) || - (Config->Relocatable && (C->getFlags() & SHF_MERGE))) - Alignment = std::max<uintX_t>(C->Alignment, C->getEntsize()); + (Config->Relocatable && (C->Flags & SHF_MERGE))) + Alignment = std::max<uintX_t>(C->Alignment, C->Entsize); - uint32_t Type = C->getType(); - return SectionKey<ELFT::Is64Bits>{OutsecName, Type, Flags, Alignment}; + return SectionKey<ELFT::Is64Bits>{OutsecName, C->Type, Flags, Alignment}; } template <class ELFT> @@ -1939,7 +1938,7 @@ OutputSectionFactory<ELFT>::create(const SectionKey<ELFT::Is64Bits> &Key, return {Sec, false}; } - uint32_t Type = C->getType(); + uint32_t Type = C->Type; switch (C->kind()) { case InputSectionBase<ELFT>::Regular: Sec = new OutputSection<ELFT>(Key.Name, Type, Flags); diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 022495490a2..550ff69f60d 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -132,7 +132,7 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body, InputSectionBase<ELFT> &C, typename ELFT::uint Offset, typename ELFT::uint Addend, RelExpr Expr) { - if (!(C.getFlags() & SHF_ALLOC)) + if (!(C.Flags & SHF_ALLOC)) return 0; if (!Body.isTls()) @@ -598,7 +598,7 @@ template <class ELFT, class RelTy> static void scanRelocs(InputSectionBase<ELFT> &C, ArrayRef<RelTy> Rels) { typedef typename ELFT::uint uintX_t; - bool IsWrite = C.getFlags() & SHF_WRITE; + bool IsWrite = C.Flags & SHF_WRITE; auto AddDyn = [=](const DynamicReloc<ELFT> &Reloc) { Out<ELFT>::RelaDyn->addReloc(Reloc); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7d54c158fd9..7728941c9db 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -346,7 +346,7 @@ static bool shouldKeepInSymtab(InputSectionBase<ELFT> *Sec, StringRef SymName, if (Config->Discard == DiscardPolicy::Locals) return false; - return !Sec || !(Sec->getFlags() & SHF_MERGE); + return !Sec || !(Sec->Flags & SHF_MERGE); } template <class ELFT> static bool includeInSymtab(const SymbolBody &B) { @@ -676,7 +676,7 @@ void Writer<ELFT>::forEachRelSec( // creating GOT, PLT, copy relocations, etc. // Note that relocations for non-alloc sections are directly // processed by InputSection::relocateNonAlloc. - if (!(IS->getFlags() & SHF_ALLOC)) + if (!(IS->Flags & SHF_ALLOC)) continue; if (auto *S = dyn_cast<InputSection<ELFT>>(IS)) { for (const Elf_Shdr *RelSec : S->RelocSections) |

