1 /*===- InstrProfiling.c - Support library for PGO instrumentation ---------===*\ 2 |* 3 |* The LLVM Compiler Infrastructure 4 |* 5 |* This file is distributed under the University of Illinois Open Source 6 |* License. See LICENSE.TXT for details. 7 |* 8 \*===----------------------------------------------------------------------===*/ 9 10 #include "InstrProfiling.h" 11 #include <string.h> 12 13 uint64_t __llvm_profile_get_magic(void) { 14 /* Magic number to detect file format and endianness. 15 * 16 * Use 255 at one end, since no UTF-8 file can use that character. Avoid 0, 17 * so that utilities, like strings, don't grab it as a string. 129 is also 18 * invalid UTF-8, and high enough to be interesting. 19 * 20 * Use "lprofr" in the centre to stand for "LLVM Profile Raw", or "lprofR" 21 * for 32-bit platforms. 22 */ 23 unsigned char R = sizeof(void *) == sizeof(uint64_t) ? 'r' : 'R'; 24 return 25 (uint64_t)255 << 56 | 26 (uint64_t)'l' << 48 | 27 (uint64_t)'p' << 40 | 28 (uint64_t)'r' << 32 | 29 (uint64_t)'o' << 24 | 30 (uint64_t)'f' << 16 | 31 (uint64_t) R << 8 | 32 (uint64_t)129; 33 } 34 35 uint64_t __llvm_profile_get_version(void) { 36 /* This should be bumped any time the output format changes. */ 37 return 1; 38 } 39 40 void __llvm_profile_reset_counters(void) { 41 uint64_t *I = __llvm_profile_counters_begin(); 42 uint64_t *E = __llvm_profile_counters_end(); 43 44 memset(I, 0, sizeof(uint64_t)*(E - I)); 45 } 46