[PATCH] D16092: [Coverage] Do not allocate memory for coverage map data (Linux)

David Li via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 11 15:39:48 PST 2016


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

Coverage mapping data is not referenced by runtime, and they won't be dumped into profile data. There is no need to allocate memory for covmap sections.

A good side effect of this change is that the coverage map data won't be mistakenly garbage collected by the linker (for Gold linker only, BFD linker has an issue where the a bug is filed).

Tested with clang build with instrumentation and -fcoverage-mapping and linker GC.   The size of covmap section is ~17.6M so the text segment size will be reduced by this amount with this change.

Need suggestion on how this is done for Mach-O.

http://reviews.llvm.org/D16092

Files:
  lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Index: lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -33,6 +33,7 @@
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbolELF.h"
 #include "llvm/MC/MCValue.h"
+#include "llvm/ProfileData/InstrProf.h"
 #include "llvm/Support/COFF.h"
 #include "llvm/Support/Dwarf.h"
 #include "llvm/Support/ELF.h"
@@ -119,6 +120,10 @@
   // section(".eh_frame") gcc will produce:
   //
   //   .section   .eh_frame,"a", at progbits
+  
+  if (Name == getInstrProfCoverageSectionName(false))
+    return SectionKind::getMetadata();
+
   if (Name.empty() || Name[0] != '.') return K;
 
   // Some lame default implementation based on some magic section names.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16092.44571.patch
Type: text/x-patch
Size: 811 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160111/02cb3f48/attachment.bin>


More information about the llvm-commits mailing list