From: Rafael Espindola Date: Wed, 26 Oct 2016 12:36:56 +0000 (+0000) Subject: Delete trivial getters. NFC. X-Git-Tag: llvmorg-4.0.0-rc1~6241 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1854a8ebb83954c9969ac49cc2ababfdd0223520;p=platform%2Fupstream%2Fllvm.git Delete trivial getters. NFC. llvm-svn: 285190 --- diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index df4f763..913902c 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 uint64_t ICF::getHash(InputSection *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 bool ICF::isEligible(InputSectionBase *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 @@ -230,7 +230,7 @@ bool ICF::equalsConstant(const InputSection *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 d407be4..506246f 100644 --- a/lld/ELF/InputSection.cpp +++ b/lld/ELF/InputSection.cpp @@ -161,7 +161,7 @@ template void InputSectionBase::uncompress() { // shouldn't be significant in ELF.) We need to be able to read both. ArrayRef 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::getOffset(const DefinedRegular &Sym) const { template InputSectionBase *InputSectionBase::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::classof(const InputSectionBase *S) { template InputSectionBase *InputSection::getRelocatedSection() { - assert(this->getType() == SHT_RELA || this->getType() == SHT_REL); + assert(this->Type == SHT_RELA || this->Type == SHT_REL); ArrayRef *> Sections = this->File->getSections(); - return Sections[this->getInfo()]; + return Sections[this->Info]; } template void InputSection::addThunk(const Thunk *T) { @@ -418,7 +418,7 @@ void InputSectionBase::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>(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::relocate(uint8_t *Buf, uint8_t *BufEnd) { } template void InputSection::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()); return; } - if (this->getType() == SHT_REL) { + if (this->Type == SHT_REL) { copyRelocations(Buf + OutSecOff, this->template getDataAs()); return; } @@ -605,7 +605,7 @@ std::vector MergeInputSection::splitStrings(ArrayRef Data, size_t EntSize) { std::vector 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::splitNonStrings(ArrayRef Data, std::vector 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::MergeInputSection(elf::ObjectFile *F, template void MergeInputSection::splitIntoPieces() { ArrayRef 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 40ae21e..cd18192 100644 --- a/lld/ELF/InputSection.h +++ b/lld/ELF/InputSection.h @@ -85,6 +85,7 @@ protected: // The file this section is from. ObjectFile *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(), false, false), Repl(this) {} @@ -117,11 +117,6 @@ public: static InputSectionBase 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 *getFile() const { return File; } uintX_t getOffset(const DefinedRegular &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 ed6dd69..3b835d9 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -156,7 +156,7 @@ static bool matchConstraints(ArrayRef *> Sections, return true; bool IsRW = llvm::any_of(Sections, [=](InputSectionData *Sec2) { auto *Sec = static_cast *>(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 createKey(InputSectionBase *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>(C)) - Alignment = std::max(C->Alignment, C->getEntsize()); + Alignment = std::max(C->Alignment, C->Entsize); return SectionKey{OutsecName, /*Type*/ 0, Flags, Alignment}; } diff --git a/lld/ELF/MarkLive.cpp b/lld/ELF/MarkLive.cpp index 4502d9d..dca1be7 100644 --- a/lld/ELF/MarkLive.cpp +++ b/lld/ELF/MarkLive.cpp @@ -135,7 +135,7 @@ scanEhFrameSection(EhInputSection &EH, ArrayRef Rels, ResolvedReloc R = resolveReloc(EH, Rels[I2]); if (!R.Sec || R.Sec == &InputSection::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 &EH, // 1) Sections used by the loader (.init, .fini, .ctors, .dtors or .jcr) // 2) Non-allocatable sections which typically contain debugging information template static bool isReserved(InputSectionBase *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 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 0bbd4ed..5566a42 100644 --- a/lld/ELF/OutputSections.cpp +++ b/lld/ELF/OutputSections.cpp @@ -966,8 +966,8 @@ void OutputSection::addSection(InputSectionBase *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::addSection(InputSectionBase *C) { auto *Sec = cast>(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::addSection(InputSectionBase *C) { template static typename ELFT::uint getOutFlags(InputSectionBase *S) { - return S->getFlags() & ~SHF_GROUP & ~SHF_COMPRESSED; + return S->Flags & ~SHF_GROUP & ~SHF_COMPRESSED; } template @@ -1913,11 +1913,10 @@ static SectionKey createKey(InputSectionBase *C, // output sections for them to allow merging at final linking stage. uintX_t Alignment = 0; if (isa>(C) || - (Config->Relocatable && (C->getFlags() & SHF_MERGE))) - Alignment = std::max(C->Alignment, C->getEntsize()); + (Config->Relocatable && (C->Flags & SHF_MERGE))) + Alignment = std::max(C->Alignment, C->Entsize); - uint32_t Type = C->getType(); - return SectionKey{OutsecName, Type, Flags, Alignment}; + return SectionKey{OutsecName, C->Type, Flags, Alignment}; } template @@ -1939,7 +1938,7 @@ OutputSectionFactory::create(const SectionKey &Key, return {Sec, false}; } - uint32_t Type = C->getType(); + uint32_t Type = C->Type; switch (C->kind()) { case InputSectionBase::Regular: Sec = new OutputSection(Key.Name, Type, Flags); diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 0224954..550ff69 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -132,7 +132,7 @@ static unsigned handleTlsRelocation(uint32_t Type, SymbolBody &Body, InputSectionBase &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 static void scanRelocs(InputSectionBase &C, ArrayRef Rels) { typedef typename ELFT::uint uintX_t; - bool IsWrite = C.getFlags() & SHF_WRITE; + bool IsWrite = C.Flags & SHF_WRITE; auto AddDyn = [=](const DynamicReloc &Reloc) { Out::RelaDyn->addReloc(Reloc); diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 7d54c15..7728941 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -346,7 +346,7 @@ static bool shouldKeepInSymtab(InputSectionBase *Sec, StringRef SymName, if (Config->Discard == DiscardPolicy::Locals) return false; - return !Sec || !(Sec->getFlags() & SHF_MERGE); + return !Sec || !(Sec->Flags & SHF_MERGE); } template static bool includeInSymtab(const SymbolBody &B) { @@ -676,7 +676,7 @@ void Writer::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>(IS)) { for (const Elf_Shdr *RelSec : S->RelocSections)