[PGO] Minor refactoring /NFC
authorXinliang David Li <davidxl@google.com>
Thu, 7 Jan 2016 22:46:29 +0000 (22:46 +0000)
committerXinliang David Li <davidxl@google.com>
Thu, 7 Jan 2016 22:46:29 +0000 (22:46 +0000)
Move common defs into common header files.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257108 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/CoverageMapping.h
include/llvm/ProfileData/InstrProf.h
include/llvm/ProfileData/InstrProfData.inc
lib/ProfileData/CoverageMappingReader.cpp

index 3790e1358449c1167fbe2d148c8dc476564281dc..ca44442001b4aafd9923544b73d73ddbe593bf3e 100644 (file)
@@ -35,8 +35,6 @@ class CoverageMappingReader;
 class CoverageMapping;
 struct CounterExpressions;
 
 class CoverageMapping;
 struct CounterExpressions;
 
-enum CoverageMappingVersion { CoverageMappingVersion1 };
-
 /// \brief A Counter is an abstract value that describes how to compute the
 /// execution count for a region of code using the collected profile count data.
 struct Counter {
 /// \brief A Counter is an abstract value that describes how to compute the
 /// execution count for a region of code using the collected profile count data.
 struct Counter {
index adf62fb56c6bcacde79f0cbd9c006e022b0b93fc..501aafdbfdc348a2cd1acff0acc1fb7f5b2c4b99 100644 (file)
@@ -30,7 +30,6 @@
 #include <system_error>
 #include <vector>
 
 #include <system_error>
 #include <vector>
 
-#define INSTR_PROF_INDEX_VERSION 3
 namespace llvm {
 
 class Function;
 namespace llvm {
 
 class Function;
@@ -66,7 +65,8 @@ inline StringRef getInstrProfValueProfFuncName() {
 /// Return the name of the section containing function coverage mapping
 /// data.
 inline StringRef getInstrProfCoverageSectionName(bool AddSegment) {
 /// Return the name of the section containing function coverage mapping
 /// data.
 inline StringRef getInstrProfCoverageSectionName(bool AddSegment) {
-  return AddSegment ? "__DATA,__llvm_covmap" : "__llvm_covmap";
+  return AddSegment ? "__DATA," INSTR_PROF_COVMAP_SECT_NAME_STR
+                    : INSTR_PROF_COVMAP_SECT_NAME_STR;
 }
 
 /// Return the name prefix of variables containing instrumented function names.
 }
 
 /// Return the name prefix of variables containing instrumented function names.
@@ -626,6 +626,12 @@ struct CovMapHeader {
 };
 
 LLVM_PACKED_END
 };
 
 LLVM_PACKED_END
+
+enum CoverageMappingVersion {
+  CoverageMappingVersion1 = 0,
+  // The current versin is Version1
+  CoverageMappingCurrentVersion = INSTR_PROF_COVMAP_VERSION
+};
 }
 
 } // end namespace llvm
 }
 
 } // end namespace llvm
index 3a7c0c5f277347f2258e595cf16dc387765da8dd..ee62eb19bad60623c11a5b058ae6e47a7bfa764b 100644 (file)
@@ -696,18 +696,23 @@ serializeValueProfDataFromRT(const ValueProfRuntimeRecord *Record,
 
 /* Raw profile format version. */
 #define INSTR_PROF_RAW_VERSION 2
 
 /* Raw profile format version. */
 #define INSTR_PROF_RAW_VERSION 2
+#define INSTR_PROF_INDEX_VERSION 3
+#define INSTR_PROF_COVMAP_VERSION 0
 
 /* Runtime section names and name strings.  */
 #define INSTR_PROF_DATA_SECT_NAME __llvm_prf_data
 #define INSTR_PROF_NAME_SECT_NAME __llvm_prf_names
 #define INSTR_PROF_CNTS_SECT_NAME __llvm_prf_cnts
 
 /* Runtime section names and name strings.  */
 #define INSTR_PROF_DATA_SECT_NAME __llvm_prf_data
 #define INSTR_PROF_NAME_SECT_NAME __llvm_prf_names
 #define INSTR_PROF_CNTS_SECT_NAME __llvm_prf_cnts
-
-#define INSTR_PROF_DATA_SECT_NAME_STR \
-        INSTR_PROF_QUOTE(INSTR_PROF_DATA_SECT_NAME)
-#define INSTR_PROF_NAME_SECT_NAME_STR \
-        INSTR_PROF_QUOTE(INSTR_PROF_NAME_SECT_NAME)
-#define INSTR_PROF_CNTS_SECT_NAME_STR \
-        INSTR_PROF_QUOTE(INSTR_PROF_CNTS_SECT_NAME)
+#define INSTR_PROF_COVMAP_SECT_NAME __llvm_covmap
+
+#define INSTR_PROF_DATA_SECT_NAME_STR                                          \
+  INSTR_PROF_QUOTE(INSTR_PROF_DATA_SECT_NAME)
+#define INSTR_PROF_NAME_SECT_NAME_STR                                          \
+  INSTR_PROF_QUOTE(INSTR_PROF_NAME_SECT_NAME)
+#define INSTR_PROF_CNTS_SECT_NAME_STR                                          \
+  INSTR_PROF_QUOTE(INSTR_PROF_CNTS_SECT_NAME)
+#define INSTR_PROF_COVMAP_SECT_NAME_STR                                        \
+  INSTR_PROF_QUOTE(INSTR_PROF_COVMAP_SECT_NAME)
 
 /* Macros to define start/stop section symbol for a given
  * section on Linux. For instance
 
 /* Macros to define start/stop section symbol for a given
  * section on Linux. For instance
index 32c692d8073a76a8664cea15fcdbb9d8da313a9d..af6c616fa0311bf0bb0f6d67e6df32f0d066d6f0 100644 (file)
@@ -328,12 +328,8 @@ static std::error_code readCoverageMappingData(
     uint32_t Version = endian::byte_swap<uint32_t, Endian>(CovHeader->Version);
     Buf = reinterpret_cast<const char *>(++CovHeader);
 
     uint32_t Version = endian::byte_swap<uint32_t, Endian>(CovHeader->Version);
     Buf = reinterpret_cast<const char *>(++CovHeader);
 
-    switch (Version) {
-    case CoverageMappingVersion1:
-      break;
-    default:
+    if (Version > coverage::CoverageMappingCurrentVersion)
       return coveragemap_error::unsupported_version;
       return coveragemap_error::unsupported_version;
-    }
 
     // Skip past the function records, saving the start and end for later.
     const char *FunBuf = Buf;
 
     // Skip past the function records, saving the start and end for later.
     const char *FunBuf = Buf;