[llvm] r257781 - [PGO] [Coverage] put covmap into note section with no 'alloc flag' (Linux)

Xinliang David Li via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 14 10:09:45 PST 2016


Author: davidxl
Date: Thu Jan 14 12:09:45 2016
New Revision: 257781

URL: http://llvm.org/viewvc/llvm-project?rev=257781&view=rev
Log:
[PGO] [Coverage] put covmap into note section with no 'alloc flag' (Linux)

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.


Modified:
    llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Modified: llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp?rev=257781&r1=257780&r2=257781&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp (original)
+++ llvm/trunk/lib/CodeGen/TargetLoweringObjectFileImpl.cpp Thu Jan 14 12:09:45 2016
@@ -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 @@ getELFKindForNamedSection(StringRef Name
   // 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.
@@ -150,6 +155,9 @@ getELFKindForNamedSection(StringRef Name
 
 static unsigned getELFSectionType(StringRef Name, SectionKind K) {
 
+  if (Name == getInstrProfCoverageSectionName(false))
+    return ELF::SHT_NOTE;
+
   if (Name == ".init_array")
     return ELF::SHT_INIT_ARRAY;
 




More information about the llvm-commits mailing list