[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.

llvm-svn: 257781
This commit is contained in:
Xinliang David Li 2016-01-14 18:09:45 +00:00
parent 1d9970a5a9
commit 5f04f926e9
1 changed files with 8 additions and 0 deletions

View File

@ -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, SectionKind K) {
// section(".eh_frame") gcc will produce:
//
// .section .eh_frame,"a",@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, SectionKind K) {
static unsigned getELFSectionType(StringRef Name, SectionKind K) {
if (Name == getInstrProfCoverageSectionName(false))
return ELF::SHT_NOTE;
if (Name == ".init_array")
return ELF::SHT_INIT_ARRAY;