[lld] r285190 - Delete trivial getters. NFC.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 05:36:57 PDT 2016


Author: rafael
Date: Wed Oct 26 07:36:56 2016
New Revision: 285190

URL: http://llvm.org/viewvc/llvm-project?rev=285190&view=rev
Log:
Delete trivial getters. NFC.

Modified:
    lld/trunk/ELF/ICF.cpp
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/ELF/InputSection.h
    lld/trunk/ELF/LinkerScript.cpp
    lld/trunk/ELF/MarkLive.cpp
    lld/trunk/ELF/OutputSections.cpp
    lld/trunk/ELF/Relocations.cpp
    lld/trunk/ELF/Writer.cpp

Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Wed Oct 26 07:36:56 2016
@@ -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>::is
   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 Inp
     }
   }
 
-  return A->getFlags() == B->getFlags() && A->getSize() == B->getSize() &&
+  return A->Flags == B->Flags && A->getSize() == B->getSize() &&
          A->Data == B->Data;
 }
 

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Oct 26 07:36:56 2016
@@ -161,7 +161,7 @@ template <class ELFT> void InputSectionB
   // 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
 
 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 I
 
 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(ui
   // 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(ui
 }
 
 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
   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>::MergeInputSecti
 
 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;
 }

Modified: lld/trunk/ELF/InputSection.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.h (original)
+++ lld/trunk/ELF/InputSection.h Wed Oct 26 07:36:56 2016
@@ -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);
   }
 

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Wed Oct 26 07:36:56 2016
@@ -156,7 +156,7 @@ static bool matchConstraints(ArrayRef<In
     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> create
   // 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};
 }

Modified: lld/trunk/ELF/MarkLive.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/MarkLive.cpp?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/MarkLive.cpp (original)
+++ lld/trunk/ELF/MarkLive.cpp Wed Oct 26 07:36:56 2016
@@ -135,7 +135,7 @@ scanEhFrameSection(EhInputSection<ELFT>
       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>
 // 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

Modified: lld/trunk/ELF/OutputSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/OutputSections.cpp?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/OutputSections.cpp (original)
+++ lld/trunk/ELF/OutputSections.cpp Wed Oct 26 07:36:56 2016
@@ -966,8 +966,8 @@ void OutputSection<ELFT>::addSection(Inp
   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>::addSectio
   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>::ad
 
 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> create
   // 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
     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);

Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Wed Oct 26 07:36:56 2016
@@ -132,7 +132,7 @@ static unsigned handleTlsRelocation(uint
                                     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);

Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=285190&r1=285189&r2=285190&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Wed Oct 26 07:36:56 2016
@@ -346,7 +346,7 @@ static bool shouldKeepInSymtab(InputSect
   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)




More information about the llvm-commits mailing list