summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ProfileData/InstrProf.cpp
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2017-04-13 23:37:12 +0000
committerXinliang David Li <davidxl@google.com>2017-04-13 23:37:12 +0000
commit57dea2d3591791147436dea198a13f7c3c82caea (patch)
tree64a6e9f9e8dd48fcb53b9a18dfc47643c3cf67b4 /llvm/lib/ProfileData/InstrProf.cpp
parentc5779460f4cbea38dc77911b667a6d76c79c1a3f (diff)
downloadbcm5719-llvm-57dea2d3591791147436dea198a13f7c3c82caea.tar.gz
bcm5719-llvm-57dea2d3591791147436dea198a13f7c3c82caea.zip
[Profile] PE binary coverage bug fix
PR/32584 Differential Revision: https://reviews.llvm.org/D32023 llvm-svn: 300277
Diffstat (limited to 'llvm/lib/ProfileData/InstrProf.cpp')
-rw-r--r--llvm/lib/ProfileData/InstrProf.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 0ec3fce4b23..d66d25eb190 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -136,8 +136,92 @@ const std::error_category &llvm::instrprof_category() {
return *ErrorCategory;
}
+namespace {
+
+enum InstrProfSectKind {
+#define INSTR_PROF_SECT_ENTRY(Kind, SectName, SectNameCommon, SectNameCoff, \
+ Prefix) \
+ Kind,
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+const char *InstrProfSectName[] = {
+#define INSTR_PROF_SECT_ENTRY(Kind, SectName, SectNameCommon, SectNameCoff, \
+ Prefix) \
+ SectName,
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+const char *InstrProfSectNameCommon[] = {
+#define INSTR_PROF_SECT_ENTRY(Kind, SectName, SectNameCommon, SectNameCoff, \
+ Prefix) \
+ SectNameCommon,
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+const char *InstrProfSectNameCoff[] = {
+#define INSTR_PROF_SECT_ENTRY(Kind, SectName, SectNameCommon, SectNameCoff, \
+ Prefix) \
+ SectNameCoff,
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+const char *InstrProfSectNamePrefix[] = {
+#define INSTR_PROF_SECT_ENTRY(Kind, SectName, SectNameCommon, SectNameCoff, \
+ Prefix) \
+ Prefix,
+#include "llvm/ProfileData/InstrProfData.inc"
+};
+
+std::string getInstrProfSectionName(const Module *M, InstrProfSectKind Kind) {
+
+ if (!M)
+ return InstrProfSectName[Kind];
+
+ bool AddSegment = Triple(M->getTargetTriple()).isOSBinFormatMachO();
+ std::string SectName;
+ if (Triple(M->getTargetTriple()).isOSBinFormatCOFF())
+ SectName = InstrProfSectNameCoff[Kind];
+ else
+ SectName = InstrProfSectNameCommon[Kind];
+
+ if (AddSegment) {
+ SectName = InstrProfSectNamePrefix[Kind] + SectName;
+ if (Kind == IPSK_data) {
+ SectName += ",regular,live_support";
+ }
+ }
+ return SectName;
+}
+
+} // namespace
+
namespace llvm {
+std::string getInstrProfCountersSectionName(const Module *M) {
+ return getInstrProfSectionName(M, IPSK_cnts);
+}
+
+std::string getInstrProfNameSectionName(const Module *M) {
+ return getInstrProfSectionName(M, IPSK_name);
+}
+
+std::string getInstrProfDataSectionName(const Module *M) {
+ return getInstrProfSectionName(M, IPSK_data);
+}
+
+std::string getInstrProfValuesSectionName(const Module *M) {
+ return getInstrProfSectionName(M, IPSK_vals);
+}
+
+std::string getInstrProfVNodesSectionName(const Module *M) {
+ return getInstrProfSectionName(M, IPSK_vnodes);
+}
+
+std::string getInstrProfCoverageSectionName(const Module *M) {
+ return getInstrProfSectionName(M, IPSK_covmap);
+}
+
void SoftInstrProfErrors::addError(instrprof_error IE) {
if (IE == instrprof_error::success)
return;
OpenPOWER on IntegriCloud