[llvm] r205577 - Remove section_rel_empty. Just compare begin() and end() instead.

Rafael Espindola rafael.espindola at gmail.com
Thu Apr 3 15:42:22 PDT 2014


Author: rafael
Date: Thu Apr  3 17:42:22 2014
New Revision: 205577

URL: http://llvm.org/viewvc/llvm-project?rev=205577&view=rev
Log:
Remove section_rel_empty. Just compare begin() and end() instead.

Modified:
    llvm/trunk/include/llvm/Object/COFF.h
    llvm/trunk/include/llvm/Object/ELFObjectFile.h
    llvm/trunk/include/llvm/Object/MachO.h
    llvm/trunk/include/llvm/Object/ObjectFile.h
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
    llvm/trunk/lib/Object/COFFObjectFile.cpp
    llvm/trunk/lib/Object/MachOObjectFile.cpp

Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=205577&r1=205576&r2=205577&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Thu Apr  3 17:42:22 2014
@@ -387,7 +387,6 @@ protected:
                                    bool &Result) const override;
   relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
   relocation_iterator section_rel_end(DataRefImpl Sec) const override;
-  bool section_rel_empty(DataRefImpl Sec) const override;
 
   void moveRelocationNext(DataRefImpl &Rel) const override;
   error_code getRelocationAddress(DataRefImpl Rel,

Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=205577&r1=205576&r2=205577&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Thu Apr  3 17:42:22 2014
@@ -89,7 +89,6 @@ protected:
                                    bool &Result) const override;
   relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
   relocation_iterator section_rel_end(DataRefImpl Sec) const override;
-  bool section_rel_empty(DataRefImpl Sec) const override;
   section_iterator getRelocatedSection(DataRefImpl Sec) const override;
 
   void moveRelocationNext(DataRefImpl &Rel) const override;
@@ -496,12 +495,6 @@ ELFObjectFile<ELFT>::section_rel_end(Dat
 }
 
 template <class ELFT>
-bool ELFObjectFile<ELFT>::section_rel_empty(DataRefImpl Sec) const {
-  const Elf_Shdr *S = reinterpret_cast<const Elf_Shdr *>(Sec.p);
-  return S->sh_size == 0;
-}
-
-template <class ELFT>
 section_iterator
 ELFObjectFile<ELFT>::getRelocatedSection(DataRefImpl Sec) const {
   if (EF.getHeader()->e_type != ELF::ET_REL)

Modified: llvm/trunk/include/llvm/Object/MachO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/MachO.h?rev=205577&r1=205576&r2=205577&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/MachO.h (original)
+++ llvm/trunk/include/llvm/Object/MachO.h Thu Apr  3 17:42:22 2014
@@ -88,7 +88,6 @@ public:
                                    bool &Result) const override;
   relocation_iterator section_rel_begin(DataRefImpl Sec) const override;
   relocation_iterator section_rel_end(DataRefImpl Sec) const override;
-  bool section_rel_empty(DataRefImpl Sec) const override;
 
   void moveRelocationNext(DataRefImpl &Rel) const override;
   error_code getRelocationAddress(DataRefImpl Rel,

Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=205577&r1=205576&r2=205577&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Thu Apr  3 17:42:22 2014
@@ -117,7 +117,6 @@ public:
   relocation_iterator_range relocations() const {
     return relocation_iterator_range(relocation_begin(), relocation_end());
   }
-  bool relocation_empty() const;
   section_iterator getRelocatedSection() const;
 
   DataRefImpl getRawDataRefImpl() const;
@@ -256,7 +255,6 @@ protected:
                                            bool &Result) const = 0;
   virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0;
   virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0;
-  virtual bool section_rel_empty(DataRefImpl Sec) const = 0;
   virtual section_iterator getRelocatedSection(DataRefImpl Sec) const;
 
   // Same as above for RelocationRef.
@@ -491,10 +489,6 @@ inline relocation_iterator SectionRef::r
   return OwningObject->section_rel_end(SectionPimpl);
 }
 
-inline bool SectionRef::relocation_empty() const {
-  return OwningObject->section_rel_empty(SectionPimpl);
-}
-
 inline section_iterator SectionRef::getRelocatedSection() const {
   return OwningObject->getRelocatedSection(SectionPimpl);
 }

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=205577&r1=205576&r2=205577&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Thu Apr  3 17:42:22 2014
@@ -163,7 +163,10 @@ ObjectImage *RuntimeDyldImpl::loadObject
     StubMap Stubs;
     section_iterator RelocatedSection = SI->getRelocatedSection();
 
-    if (SI->relocation_empty() && !ProcessAllSections)
+    relocation_iterator I = SI->relocation_begin();
+    relocation_iterator E = SI->relocation_end();
+
+    if (I == E && !ProcessAllSections)
       continue;
 
     bool IsCode = false;
@@ -172,8 +175,7 @@ ObjectImage *RuntimeDyldImpl::loadObject
         findOrEmitSection(*Obj, *RelocatedSection, IsCode, LocalSections);
     DEBUG(dbgs() << "\tSectionID: " << SectionID << "\n");
 
-    for (relocation_iterator I = SI->relocation_begin(),
-         E = SI->relocation_end(); I != E;)
+    for (; I != E;)
       I = processRelocationRef(SectionID, I, *Obj, LocalSections, LocalSymbols,
                                Stubs);
   }

Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=205577&r1=205576&r2=205577&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Thu Apr  3 17:42:22 2014
@@ -389,11 +389,6 @@ relocation_iterator COFFObjectFile::sect
   return relocation_iterator(RelocationRef(Ret, this));
 }
 
-bool COFFObjectFile::section_rel_empty(DataRefImpl Ref) const {
-  const coff_section *Sec = toSec(Ref);
-  return Sec->NumberOfRelocations == 0;
-}
-
 // Initialize the pointer to the symbol table.
 error_code COFFObjectFile::initSymbolTablePtr() {
   if (error_code EC = getObject(

Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=205577&r1=205576&r2=205577&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Apr  3 17:42:22 2014
@@ -791,16 +791,6 @@ MachOObjectFile::section_rel_end(DataRef
   return relocation_iterator(RelocationRef(Ret, this));
 }
 
-bool MachOObjectFile::section_rel_empty(DataRefImpl Sec) const {
-  if (is64Bit()) {
-    MachO::section_64 Sect = getSection64(Sec);
-    return Sect.nreloc == 0;
-  } else {
-    MachO::section Sect = getSection(Sec);
-    return Sect.nreloc == 0;
-  }
-}
-
 void MachOObjectFile::moveRelocationNext(DataRefImpl &Rel) const {
   const MachO::any_relocation_info *P =
     reinterpret_cast<const MachO::any_relocation_info *>(Rel.p);





More information about the llvm-commits mailing list