blob: 9dd753974fca18934a44c29ff0dca4d4182b3ba4 [file] [log] [blame]
Duncan P. N. Exon Smith8353a262014-03-19 22:10:27 +00001/*===- 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)
24typedef unsigned int uint32_t;
25typedef 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"
31typedef unsigned int uint32_t;
32typedef unsigned long long uint64_t;
33#endif
34
Duncan P. N. Exon Smith9edbae02014-03-20 20:00:44 +000035typedef struct __llvm_profile_data {
Duncan P. N. Exon Smith8353a262014-03-19 22:10:27 +000036 const uint32_t NameSize;
37 const uint32_t NumCounters;
38 const uint64_t FuncHash;
39 const char *const Name;
Duncan P. N. Exon Smithf1212172014-03-20 19:44:31 +000040 uint64_t *const Counters;
Duncan P. N. Exon Smith9edbae02014-03-20 20:00:44 +000041} __llvm_profile_data;
Duncan P. N. Exon Smith8353a262014-03-19 22:10:27 +000042
Duncan P. N. Exon Smith9edbae02014-03-20 20:00:44 +000043/* TODO: void __llvm_profile_get_size_for_buffer(void); */
Duncan P. N. Exon Smith8353a262014-03-19 22:10:27 +000044
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 Smith9edbae02014-03-20 20:00:44 +000052void __llvm_profile_write_buffer(FILE *OutputFile);
Duncan P. N. Exon Smithda0de8a22014-03-20 03:23:10 +000053
Duncan P. N. Exon Smith9edbae02014-03-20 20:00:44 +000054const __llvm_profile_data *__llvm_profile_data_begin();
55const __llvm_profile_data *__llvm_profile_data_end();
56const char *__llvm_profile_names_begin();
57const char *__llvm_profile_names_end();
58uint64_t *__llvm_profile_counters_begin();
59uint64_t *__llvm_profile_counters_end();