summaryrefslogtreecommitdiff
path: root/lib/profile/InstrProfiling.c
diff options
context:
space:
mode:
authorXinliang David Li <davidxl@google.com>2015-11-23 17:26:53 +0000
committerXinliang David Li <davidxl@google.com>2015-11-23 17:26:53 +0000
commit6df39b718e0f01cbdba31d87a5c8d6a06b13e833 (patch)
treede4c71ba42aae1cba00f8957c2ac1456a2ffcf02 /lib/profile/InstrProfiling.c
parent23376279ecdecdcbdc9597eeb8491e17488087ac (diff)
[PGO] Use common definition of raw magic and version
- Replace duplicate definition and use of magic in profile runtime - Replace hard coded version reference in profile runtime git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@253885 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/profile/InstrProfiling.c')
-rw-r--r--lib/profile/InstrProfiling.c18
1 files changed, 3 insertions, 15 deletions
diff --git a/lib/profile/InstrProfiling.c b/lib/profile/InstrProfiling.c
index dede45bc8..58097f7d3 100644
--- a/lib/profile/InstrProfiling.c
+++ b/lib/profile/InstrProfiling.c
@@ -13,19 +13,8 @@
#include <string.h>
LLVM_LIBRARY_VISIBILITY uint64_t __llvm_profile_get_magic(void) {
- /* 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.
- */
- unsigned char R = sizeof(void *) == sizeof(uint64_t) ? 'r' : 'R';
- 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;
+ return sizeof(void *) == sizeof(uint64_t) ? (INSTR_PROF_RAW_MAGIC_64)
+ : (INSTR_PROF_RAW_MAGIC_32);
}
/* Return the number of bytes needed to add to SizeInBytes to make it
@@ -37,8 +26,7 @@ __llvm_profile_get_num_padding_bytes(uint64_t SizeInBytes) {
}
LLVM_LIBRARY_VISIBILITY uint64_t __llvm_profile_get_version(void) {
- /* This should be bumped any time the output format changes. */
- return 2;
+ return INSTR_PROF_RAW_VERSION;
}
LLVM_LIBRARY_VISIBILITY void __llvm_profile_reset_counters(void) {