[PATCH] D17309: [coverage] covmap section can now be emitted as 'progbits' without alloc flag set

David Li via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 16 16:19:16 PST 2016


davidxl created this revision.
davidxl added reviewers: vsk, davidb.
davidxl added a subscriber: llvm-commits.

Historically, there were two problems with covmap section emission in LLVM: 1) the section is emitted with 'alloc' bit set, resulting in increased loadable segment size; 2) the covmap section would be removed by the linker if -gc-sections option is on (both gold and bfd linker)

In http://reviews.llvm.org/D16092, both issues were resolved, but in order to make BFD linker not GC covmap, the covmap section was also marked as a note section due to a different design choice between bfd ld and the gold linker.  

Comment #8 in https://sourceware.org/bugzilla/show_bug.cgi?id=19446 has a good summary. Basically if a non-alloc section has a reference to another symbol which is not otherwise referenced, the linker will choose to discard the referencing section in order to garbage collect the other symbol.  The linker will keep the section if there is no such references in the section (verified with 2.24 and 2.26).

At the time of that patch, the covmap has reference to the PGO name symbol thus we had the GC problem. Most recently, we have enabled name compression in LLVM for PGO/coverage, which means covmap no longer has references to other symbols and bfd linker will leave them alone without GC them. This means we no longer need to mark covmap section as SHT_NOTE.   



http://reviews.llvm.org/D17309

Files:
  lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -155,9 +155,6 @@
 
 static unsigned getELFSectionType(StringRef Name, SectionKind K) {
 
-  if (Name == getInstrProfCoverageSectionName(false))
-    return ELF::SHT_NOTE;
-
   if (Name == ".init_array")
     return ELF::SHT_INIT_ARRAY;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17309.48121.patch
Type: text/x-patch
Size: 459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160217/06a16974/attachment.bin>


More information about the llvm-commits mailing list