[lld] r283340 - Simplify setting the Live bit in SectionPiece. NFC.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 07:33:05 PDT 2016


r283556. Thanks.



On 5 October 2016 at 13:41, Rui Ueyama <ruiu at google.com> wrote:
> On Wed, Oct 5, 2016 at 10:02 AM, Rafael Espindola via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: rafael
>> Date: Wed Oct  5 12:02:09 2016
>> New Revision: 283340
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=283340&view=rev
>> Log:
>> Simplify setting the Live bit in SectionPiece. NFC.
>>
>> Modified:
>>     lld/trunk/ELF/InputSection.cpp
>>     lld/trunk/ELF/InputSection.h
>>
>> Modified: lld/trunk/ELF/InputSection.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=283340&r1=283339&r2=283340&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/ELF/InputSection.cpp (original)
>> +++ lld/trunk/ELF/InputSection.cpp Wed Oct  5 12:02:09 2016
>> @@ -533,12 +533,13 @@ std::vector<SectionPiece>
>>  MergeInputSection<ELFT>::splitStrings(ArrayRef<uint8_t> Data, size_t
>> EntSize) {
>>    std::vector<SectionPiece> V;
>>    size_t Off = 0;
>> +  bool IsAlloca = this->getSectionHdr()->sh_flags & SHF_ALLOC;
>>    while (!Data.empty()) {
>>      size_t End = findNull(Data, EntSize);
>>      if (End == StringRef::npos)
>>        fatal(getName(this) + ": string is not null terminated");
>>      size_t Size = End + EntSize;
>> -    V.emplace_back(Off, Data.slice(0, Size));
>> +    V.emplace_back(Off, Data.slice(0, Size), !IsAlloca);
>>      Data = Data.slice(Size);
>>      Off += Size;
>>    }
>> @@ -573,16 +574,9 @@ template <class ELFT> void MergeInputSec
>>    else
>>      this->Pieces = splitNonStrings(Data, EntSize);
>>
>> -  if (Config->GcSections) {
>> -    if (this->getSectionHdr()->sh_flags & SHF_ALLOC) {
>> -      for (uintX_t Off : LiveOffsets)
>> -        this->getSectionPiece(Off)->Live = true;
>> -      return;
>> -    }
>> -
>> -    for (SectionPiece &Piece : this->Pieces)
>> -      Piece.Live = true;
>> -  }
>> +  if (Config->GcSections && this->getSectionHdr()->sh_flags & SHF_ALLOC)
>
>
> nit: add () around &.
>
>>
>> +    for (uintX_t Off : LiveOffsets)
>> +      this->getSectionPiece(Off)->Live = true;
>>  }
>>
>>  template <class ELFT>
>>
>> Modified: lld/trunk/ELF/InputSection.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.h?rev=283340&r1=283339&r2=283340&view=diff
>>
>> ==============================================================================
>> --- lld/trunk/ELF/InputSection.h (original)
>> +++ lld/trunk/ELF/InputSection.h Wed Oct  5 12:02:09 2016
>> @@ -122,9 +122,9 @@ template <class ELFT> InputSectionBase<E
>>
>>  // SectionPiece represents a piece of splittable section contents.
>>  struct SectionPiece {
>> -  SectionPiece(size_t Off, ArrayRef<uint8_t> Data)
>> +  SectionPiece(size_t Off, ArrayRef<uint8_t> Data, bool Live = false)
>>        : InputOff(Off), Data((const uint8_t *)Data.data()),
>> Size(Data.size()),
>> -        Live(!Config->GcSections) {}
>> +        Live(Live || !Config->GcSections) {}
>>
>>    ArrayRef<uint8_t> data() { return {Data, Size}; }
>>    size_t size() const { return Size; }
>>
>>
>> _______________________________________________
>> 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