[lld] r284598 - Don't gc non-alloca non-string pieces.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 07:50:26 PDT 2016


Author: rafael
Date: Wed Oct 19 09:50:26 2016
New Revision: 284598

URL: http://llvm.org/viewvc/llvm-project?rev=284598&view=rev
Log:
Don't gc non-alloca non-string pieces.

We were already doing it for strings. This matches the behavior of
bfd and gold.

Modified:
    lld/trunk/ELF/InputSection.cpp
    lld/trunk/test/ELF/debug-gc.s

Modified: lld/trunk/ELF/InputSection.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/InputSection.cpp?rev=284598&r1=284597&r2=284598&view=diff
==============================================================================
--- lld/trunk/ELF/InputSection.cpp (original)
+++ lld/trunk/ELF/InputSection.cpp Wed Oct 19 09:50:26 2016
@@ -615,8 +615,9 @@ MergeInputSection<ELFT>::splitNonStrings
   std::vector<SectionPiece> V;
   size_t Size = Data.size();
   assert((Size % EntSize) == 0);
+  bool IsAlloca = this->getSectionHdr()->sh_flags & SHF_ALLOC;
   for (unsigned I = 0, N = Size; I != N; I += EntSize)
-    V.emplace_back(I, Data.slice(I, EntSize));
+    V.emplace_back(I, Data.slice(I, EntSize), !IsAlloca);
   return V;
 }
 

Modified: lld/trunk/test/ELF/debug-gc.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/debug-gc.s?rev=284598&r1=284597&r2=284598&view=diff
==============================================================================
--- lld/trunk/test/ELF/debug-gc.s (original)
+++ lld/trunk/test/ELF/debug-gc.s Wed Oct 19 09:50:26 2016
@@ -5,6 +5,8 @@
 
 # CHECK:      Contents of section .debug_str:
 # CHECK-NEXT:  0000 41414100 42424200 43434300           AAA.BBB.CCC.
+# CHECK:      Contents of section .foo:
+# CHECK-NEXT:  0000 2a000000
 # CHECK:      Contents of section .debug_info:
 # CHECK-NEXT:  0000 00000000 04000000
 
@@ -19,6 +21,10 @@ _start:
 .Linfo_string2:
   .asciz "CCC"
 
+.section .foo,"M", at progbits,4
+.p2align 2
+  .long 42
+
 .section  .debug_info,"", at progbits
   .long .Linfo_string0
   .long .Linfo_string1




More information about the llvm-commits mailing list