[PGO] Fix remaining bugs in ProfData template file (when used by compiler-rt)
authorXinliang David Li <davidxl@google.com>
Mon, 23 Nov 2015 03:49:07 +0000 (03:49 +0000)
committerXinliang David Li <davidxl@google.com>
Mon, 23 Nov 2015 03:49:07 +0000 (03:49 +0000)
1. move const qualifier out of raw header field type as runtime use of the header
   needs to initialze the fields
2. use C style casting for integer types.

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

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

index 6eea531e589df317a8b854d3f1377bd7daf6da86..ec08166492487837f451b7f389f7418d64624a54 100644 (file)
@@ -606,7 +606,7 @@ template <class IntPtrT> struct LLVM_ALIGNAS(8) ProfileData {
 // compiler-rt/lib/profile/InstrProfilingFile.c  and
 // InstrProfilingBuffer.c.
 struct Header {
-#define INSTR_PROF_RAW_HEADER(Type, Name, Init) Type Name;
+#define INSTR_PROF_RAW_HEADER(Type, Name, Init) const Type Name;
 #include "llvm/ProfileData/InstrProfData.inc"
 };
 
index 31173cb7ee6d0ed18d785fa7f619a1e48e92efcb..63447ce8ca73b4c089ede1197267fa8d0d40b97f 100644 (file)
@@ -94,16 +94,16 @@ INSTR_PROF_DATA(const uint16_t, Int16ArrayTy, NumValueSites[IPVK_Last+1], \
 #else
 #define INSTR_PROF_DATA_DEFINED
 #endif
-INSTR_PROF_RAW_HEADER(const uint64_t, Magic, __llvm_profile_get_magic())
-INSTR_PROF_RAW_HEADER(const uint64_t, Version, __llvm_profile_get_version())
-INSTR_PROF_RAW_HEADER(const uint64_t, DataSize, DataSize)
-INSTR_PROF_RAW_HEADER(const uint64_t, CountersSize, CountersSize)
-INSTR_PROF_RAW_HEADER(const uint64_t, NamesSize,  NameSize)
-INSTR_PROF_RAW_HEADER(const uint64_t, CountersDelta, (uintptr_t)CountersBegin)
-INSTR_PROF_RAW_HEADER(const uint64_t, NamesDelta, (uintptr_t)NamesBegin)
-INSTR_PROF_RAW_HEADER(const uint64_t, ValueKindLast, IPVK_Last)
-INSTR_PROF_RAW_HEADER(const uint64_t, ValueDataSize, ValueDataSize)
-INSTR_PROF_RAW_HEADER(const uint64_t, ValueDataDelta, (uintptr_t)ValueDataBegin)
+INSTR_PROF_RAW_HEADER(uint64_t, Magic, __llvm_profile_get_magic())
+INSTR_PROF_RAW_HEADER(uint64_t, Version, __llvm_profile_get_version())
+INSTR_PROF_RAW_HEADER(uint64_t, DataSize, DataSize)
+INSTR_PROF_RAW_HEADER(uint64_t, CountersSize, CountersSize)
+INSTR_PROF_RAW_HEADER(uint64_t, NamesSize,  NamesSize)
+INSTR_PROF_RAW_HEADER(uint64_t, CountersDelta, (uintptr_t)CountersBegin)
+INSTR_PROF_RAW_HEADER(int64_t, NamesDelta, (uintptr_t)NamesBegin)
+INSTR_PROF_RAW_HEADER(uint64_t, ValueKindLast, IPVK_Last)
+INSTR_PROF_RAW_HEADER(uint64_t, ValueDataSize, ValueDataSize)
+INSTR_PROF_RAW_HEADER(uint64_t, ValueDataDelta, (uintptr_t)ValueDataBegin)
 #undef INSTR_PROF_RAW_HEADER
 /* INSTR_PROF_RAW_HEADER  end */
 
@@ -193,12 +193,12 @@ COVMAP_FUNC_RECORD(const uint64_t, llvm::Type::getInt64Ty(Ctx), FuncHash, \
  * 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)
+#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