[PGO] move raw magic and version def to InstrProfData.inc
authorXinliang David Li <davidxl@google.com>
Sun, 22 Nov 2015 02:05:50 +0000 (02:05 +0000)
committerXinliang David Li <davidxl@google.com>
Sun, 22 Nov 2015 02:05:50 +0000 (02:05 +0000)
These are shared definitions too. (NFC)

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

include/llvm/ProfileData/InstrProf.h
include/llvm/ProfileData/InstrProfData.inc

index 571e2881dce8c6a810c2d4be2b5af56b11c9aeec..4cd4ef9ee8f1d807967ba00497ff5f55dceef925 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/IR/GlobalValue.h"
+#include "llvm/ProfileData/InstrProfData.inc"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/Endian.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ErrorOr.h"
@@ -570,31 +571,15 @@ struct Header {
 
 namespace RawInstrProf {
 
 
 namespace RawInstrProf {
 
-const uint64_t Version = 2;
-
-// Magic number to detect file format and endianness.
-// Use 255 at one end, since no UTF-8 file can use that character.  Avoid 0,
-// so that utilities, like strings, don't grab it as a string.  129 is also
-// invalid UTF-8, and high enough to be interesting.
-// Use "lprofr" in the centre to stand for "LLVM Profile Raw", or "lprofR"
-// for 32-bit platforms.
-// The magic and version need to be kept in sync with
-// projects/compiler-rt/lib/profile/InstrProfiling.c
+const uint64_t Version = INSTR_PROF_RAW_VERSION;
 
 
-template <class IntPtrT>
-inline uint64_t getMagic();
-template <>
-inline uint64_t getMagic<uint64_t>() {
-  return uint64_t(255) << 56 | uint64_t('l') << 48 | uint64_t('p') << 40 |
-         uint64_t('r') << 32 | uint64_t('o') << 24 | uint64_t('f') << 16 |
-         uint64_t('r') << 8 | uint64_t(129);
+template <class IntPtrT> inline uint64_t getMagic();
+template <> inline uint64_t getMagic<uint64_t>() {
+  return INSTR_PROF_RAW_MAGIC_64;
 }
 
 }
 
-template <>
-inline uint64_t getMagic<uint32_t>() {
-  return uint64_t(255) << 56 | uint64_t('l') << 48 | uint64_t('p') << 40 |
-         uint64_t('r') << 32 | uint64_t('o') << 24 | uint64_t('f') << 16 |
-         uint64_t('R') << 8 | uint64_t(129);
+template <> inline uint64_t getMagic<uint32_t>() {
+  return INSTR_PROF_RAW_MAGIC_32;
 }
 
 // Per-function profile data header/control structure.
 }
 
 // Per-function profile data header/control structure.
index 6c9bf2725a9b8c6af76612e4d848bf0272d5b0cc..1452baeb06f5c6ae572a6afba6a60a9429589b90 100644 (file)
@@ -176,6 +176,24 @@ COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
 #ifndef INSTR_PROF_DATA_INC_
 #define INSTR_PROF_DATA_INC_
 
 #ifndef INSTR_PROF_DATA_INC_
 #define INSTR_PROF_DATA_INC_
 
+/* Magic number to detect file format and endianness.
+ * Use 255 at one end, since no UTF-8 file can use that character.  Avoid 0,             
+ * so that utilities, like strings, don't grab it as a string.  129 is also              
+ * invalid UTF-8, and high enough to be interesting.
+ * Use "lprofr" in the centre to stand for "LLVM Profile Raw", or "lprofR"               
+ * for 32-bit platforms.
+ * The magic and version need to be kept in sync with                                    
+ * projects/compiler-rt/lib/profile/InstrProfiling.c                                     
+ */
+#define INSTR_PROF_RAW_MAGIC_64 uint64_t(255) << 56 | uint64_t('l') << 48 | \
+       uint64_t('p') << 40 | uint64_t('r') << 32 | uint64_t('o') << 24 |  \
+        uint64_t('f') << 16 | uint64_t('r') << 8 | uint64_t(129)
+#define INSTR_PROF_RAW_MAGIC_32 uint64_t(255) << 56 | uint64_t('l') << 48 | \
+       uint64_t('p') << 40 | uint64_t('r') << 32 | uint64_t('o') << 24 |  \
+        uint64_t('f') << 16 | uint64_t('R') << 8 | uint64_t(129)
+
+/* Raw profile format version. */
+#define INSTR_PROF_RAW_VERSION 2
 
 #endif /* INSTR_PROF_DATA_INC_ */
 
 
 #endif /* INSTR_PROF_DATA_INC_ */