[lld] r290164 - Remove `Compressed` member from InputSectionData.

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 20 05:51:48 PST 2016


Thanks!


Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:

> Author: ruiu
> Date: Mon Dec 19 23:47:55 2016
> New Revision: 290164
>
> URL: http://llvm.org/viewvc/llvm-project?rev=290164&view=rev
> Log:
> Remove `Compressed` member from InputSectionData.
>
> This value is used only once, and we can compute a value.
> So we don't need to save it.
>
> Modified:
>     lld/trunk/ELF/Driver.cpp
>     lld/trunk/ELF/InputSection.cpp
>     lld/trunk/ELF/InputSection.h
>
> Modified: lld/trunk/ELF/Driver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=290164&r1=290163&r2=290164&view=diff
> ==============================================================================
> --- lld/trunk/ELF/Driver.cpp (original)
> +++ lld/trunk/ELF/Driver.cpp Mon Dec 19 23:47:55 2016
> @@ -827,7 +827,7 @@ template <class ELFT> void LinkerDriver:
>            [](InputSectionBase<ELFT> *S) {
>              if (!S->Live)
>                return;
> -            if (S->Compressed)
> +            if (S->isCompressed())
>                S->uncompress();
>              if (auto *MS = dyn_cast<MergeInputSection<ELFT>>(S))
>                MS->splitIntoPieces();
>
> Modified: lld/trunk/ELF/InputSection.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=290164&r1=290163&r2=290164&view=diff
> ==============================================================================
> --- lld/trunk/ELF/InputSection.cpp (original)
> +++ lld/trunk/ELF/InputSection.cpp Mon Dec 19 23:47:55 2016
> @@ -46,13 +46,6 @@ static ArrayRef<uint8_t> getSectionConte
>    return check(File->getObj().getSectionContents(Hdr));
>  }
>  
> -// ELF supports ZLIB-compressed section. Returns true if the section
> -// is compressed.
> -template <class ELFT>
> -static bool isCompressed(typename ELFT::uint Flags, StringRef Name) {
> -  return (Flags & SHF_COMPRESSED) || Name.startswith(".zdebug");
> -}
> -
>  template <class ELFT>
>  InputSectionBase<ELFT>::InputSectionBase(elf::ObjectFile<ELFT> *File,
>                                           uintX_t Flags, uint32_t Type,
> @@ -60,7 +53,7 @@ InputSectionBase<ELFT>::InputSectionBase
>                                           uint32_t Info, uintX_t Addralign,
>                                           ArrayRef<uint8_t> Data, StringRef Name,
>                                           Kind SectionKind)
> -    : InputSectionData(SectionKind, Name, Data, isCompressed<ELFT>(Flags, Name),
> +    : InputSectionData(SectionKind, Name, Data,
>                         !Config->GcSections || !(Flags & SHF_ALLOC)),
>        File(File), Flags(Flags), Entsize(Entsize), Type(Type), Link(Link),
>        Info(Info), Repl(this) {
> @@ -135,6 +128,10 @@ typename ELFT::uint InputSectionBase<ELF
>    llvm_unreachable("invalid section kind");
>  }
>  
> +template <class ELFT> bool InputSectionBase<ELFT>::isCompressed() const {
> +  return (Flags & SHF_COMPRESSED) || Name.startswith(".zdebug");
> +}
> +
>  // Returns compressed data and its size when uncompressed.
>  template <class ELFT>
>  std::pair<ArrayRef<uint8_t>, uint64_t>
>
> Modified: lld/trunk/ELF/InputSection.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=290164&r1=290163&r2=290164&view=diff
> ==============================================================================
> --- lld/trunk/ELF/InputSection.h (original)
> +++ lld/trunk/ELF/InputSection.h Mon Dec 19 23:47:55 2016
> @@ -45,9 +45,9 @@ public:
>    // The garbage collector sets sections' Live bits.
>    // If GC is disabled, all sections are considered live by default.
>    InputSectionData(Kind SectionKind, StringRef Name, ArrayRef<uint8_t> Data,
> -                   bool Compressed, bool Live)
> -      : SectionKind(SectionKind), Live(Live), Assigned(false),
> -        Compressed(Compressed), Name(Name), Data(Data) {}
> +                   bool Live)
> +      : SectionKind(SectionKind), Live(Live), Assigned(false), Name(Name),
> +        Data(Data) {}
>  
>  private:
>    unsigned SectionKind : 3;
> @@ -57,7 +57,6 @@ public:
>  
>    unsigned Live : 1;       // for garbage collection
>    unsigned Assigned : 1;   // for linker script
> -  unsigned Compressed : 1; // true if section data is compressed
>    uint32_t Alignment;
>    StringRef Name;
>    ArrayRef<uint8_t> Data;
> @@ -94,8 +93,7 @@ public:
>    uint32_t Info;
>  
>    InputSectionBase()
> -      : InputSectionData(Regular, "", ArrayRef<uint8_t>(), false, false),
> -        Repl(this) {
> +      : InputSectionData(Regular, "", ArrayRef<uint8_t>(), false), Repl(this) {
>      NumRelocations = 0;
>      AreRelocsRela = false;
>    }
> @@ -140,6 +138,9 @@ public:
>    // section.
>    uintX_t getOffset(uintX_t Offset) const;
>  
> +  // ELF supports ZLIB-compressed section.
> +  // Returns true if the section is compressed.
> +  bool isCompressed() const;
>    void uncompress();
>  
>    // Returns a source location string. Used to construct an error message.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list