Duncan P. N. Exon Smith | 8353a26 | 2014-03-19 22:10:27 +0000 | [diff] [blame] | 1 | /*===- InstrProfiling.h- 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 <stdio.h> |
| 11 | #include <stdlib.h> |
| 12 | |
| 13 | #define I386_FREEBSD (defined(__FreeBSD__) && defined(__i386__)) |
| 14 | |
| 15 | #if !I386_FREEBSD |
| 16 | #include <inttypes.h> |
| 17 | #endif |
| 18 | |
| 19 | #if !defined(_MSC_VER) && !I386_FREEBSD |
| 20 | #include <stdint.h> |
| 21 | #endif |
| 22 | |
| 23 | #if defined(_MSC_VER) |
| 24 | typedef unsigned int uint32_t; |
| 25 | typedef unsigned long long uint64_t; |
| 26 | #elif I386_FREEBSD |
| 27 | /* System headers define 'size_t' incorrectly on x64 FreeBSD (prior to |
| 28 | * FreeBSD 10, r232261) when compiled in 32-bit mode. |
| 29 | */ |
| 30 | #define PRIu64 "llu" |
| 31 | typedef unsigned int uint32_t; |
| 32 | typedef unsigned long long uint64_t; |
| 33 | #endif |
| 34 | |
Duncan P. N. Exon Smith | 9edbae0 | 2014-03-20 20:00:44 +0000 | [diff] [blame^] | 35 | typedef struct __llvm_profile_data { |
Duncan P. N. Exon Smith | 8353a26 | 2014-03-19 22:10:27 +0000 | [diff] [blame] | 36 | const uint32_t NameSize; |
| 37 | const uint32_t NumCounters; |
| 38 | const uint64_t FuncHash; |
| 39 | const char *const Name; |
Duncan P. N. Exon Smith | f121217 | 2014-03-20 19:44:31 +0000 | [diff] [blame] | 40 | uint64_t *const Counters; |
Duncan P. N. Exon Smith | 9edbae0 | 2014-03-20 20:00:44 +0000 | [diff] [blame^] | 41 | } __llvm_profile_data; |
Duncan P. N. Exon Smith | 8353a26 | 2014-03-19 22:10:27 +0000 | [diff] [blame] | 42 | |
Duncan P. N. Exon Smith | 9edbae0 | 2014-03-20 20:00:44 +0000 | [diff] [blame^] | 43 | /* TODO: void __llvm_profile_get_size_for_buffer(void); */ |
Duncan P. N. Exon Smith | 8353a26 | 2014-03-19 22:10:27 +0000 | [diff] [blame] | 44 | |
| 45 | /*! |
| 46 | * \brief Write instrumentation data to the given buffer. |
| 47 | * |
| 48 | * This function is currently broken: it shouldn't rely on libc, but it does. |
| 49 | * It should be changed to take a char* buffer, and write binary data directly |
| 50 | * to it. |
| 51 | */ |
Duncan P. N. Exon Smith | 9edbae0 | 2014-03-20 20:00:44 +0000 | [diff] [blame^] | 52 | void __llvm_profile_write_buffer(FILE *OutputFile); |
Duncan P. N. Exon Smith | da0de8a2 | 2014-03-20 03:23:10 +0000 | [diff] [blame] | 53 | |
Duncan P. N. Exon Smith | 9edbae0 | 2014-03-20 20:00:44 +0000 | [diff] [blame^] | 54 | const __llvm_profile_data *__llvm_profile_data_begin(); |
| 55 | const __llvm_profile_data *__llvm_profile_data_end(); |
| 56 | const char *__llvm_profile_names_begin(); |
| 57 | const char *__llvm_profile_names_end(); |
| 58 | uint64_t *__llvm_profile_counters_begin(); |
| 59 | uint64_t *__llvm_profile_counters_end(); |