[lld] r283340 - Simplify setting the Live bit in SectionPiece. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 5 10:02:09 PDT 2016
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)
+ 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; }
More information about the llvm-commits
mailing list