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