[PATCH] D25033: [ELF] GC: Mark all pieces of mergeable section live.
Eugene Leviant via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 28 09:21:09 PDT 2016
evgeny777 created this revision.
evgeny777 added reviewers: ruiu, grimar, rafael.
evgeny777 added subscribers: ikudrin, llvm-commits.
evgeny777 set the repository for this revision to rL LLVM.
evgeny777 added a project: lld.
The .comment section may have multiple pieces. Current revision will only live the very first piece alive
Repository:
rL LLVM
https://reviews.llvm.org/D25033
Files:
ELF/InputSection.cpp
ELF/MarkLive.cpp
test/ELF/debug-gc.s
Index: test/ELF/debug-gc.s
===================================================================
--- test/ELF/debug-gc.s
+++ test/ELF/debug-gc.s
@@ -4,7 +4,7 @@
# RUN: llvm-objdump -s %t1 | FileCheck %s
# CHECK: Contents of section .debug_str:
-# CHECK-NEXT: 0000 41414100 42424200 AAA.BBB.
+# CHECK-NEXT: 0000 41414100 42424200 43434300 AAA.BBB.CCC.
# CHECK: Contents of section .debug_info:
# CHECK-NEXT: 0000 00000000 04000000
Index: ELF/MarkLive.cpp
===================================================================
--- ELF/MarkLive.cpp
+++ ELF/MarkLive.cpp
@@ -64,20 +64,13 @@
return Rel.r_addend;
}
-template <class ELFT> static bool IsAlloc(InputSectionBase<ELFT> &Sec) {
- return (&Sec != &InputSection<ELFT>::Discarded) &&
- (Sec.getSectionHdr()->sh_flags & SHF_ALLOC);
-}
-
template <class ELFT, class RelT>
static ResolvedReloc<ELFT> resolveReloc(InputSectionBase<ELFT> &Sec,
RelT &Rel) {
SymbolBody &B = Sec.getFile()->getRelocTargetSym(Rel);
auto *D = dyn_cast<DefinedRegular<ELFT>>(&B);
if (!D || !D->Section)
return {nullptr, 0};
- if (!IsAlloc<ELFT>(Sec) && IsAlloc<ELFT>(*D->Section))
- return {nullptr, 0};
typename ELFT::uint Offset = D->Value;
if (D->isSection())
Offset += getAddend(Sec, Rel);
@@ -215,7 +208,8 @@
return;
R.Sec->Live = true;
if (InputSection<ELFT> *S = dyn_cast<InputSection<ELFT>>(R.Sec))
- Q.push_back(S);
+ if (S->getSectionHdr()->sh_flags & SHF_ALLOC)
+ Q.push_back(S);
};
auto MarkSymbol = [&](const SymbolBody *Sym) {
Index: ELF/InputSection.cpp
===================================================================
--- ELF/InputSection.cpp
+++ ELF/InputSection.cpp
@@ -572,9 +572,16 @@
else
this->Pieces = splitNonStrings(Data, EntSize);
- if (Config->GcSections)
- for (uintX_t Off : LiveOffsets)
- this->getSectionPiece(Off)->Live = true;
+ 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;
+ }
}
template <class ELFT>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25033.72848.patch
Type: text/x-patch
Size: 2268 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160928/c6c1ea38/attachment.bin>
More information about the llvm-commits
mailing list