llvm-project/compiler-rt/lib/profile/InstrProfiling.h
Duncan P. N. Exon Smith da0de8a237 PGO: Split out initialization of section bounds
Currently we register instrumentation data at runtime to determine the
bounds of the sections where the data lives.  Soon we'll implement
platform-specific linker magic to determine this at link time.

Move this logic to a separate file, so that our build system can choose
the correct platform-specific code.

No functionality change intended.

<rdar://problem/15943240>

llvm-svn: 204299
2014-03-20 03:23:10 +00:00

60 lines
1.7 KiB
C

/*===- InstrProfiling.h- 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 <stdio.h>
#include <stdlib.h>
#define I386_FREEBSD (defined(__FreeBSD__) && defined(__i386__))
#if !I386_FREEBSD
#include <inttypes.h>
#endif
#if !defined(_MSC_VER) && !I386_FREEBSD
#include <stdint.h>
#endif
#if defined(_MSC_VER)
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#elif I386_FREEBSD
/* System headers define 'size_t' incorrectly on x64 FreeBSD (prior to
* FreeBSD 10, r232261) when compiled in 32-bit mode.
*/
#define PRIu64 "llu"
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#endif
typedef struct __llvm_pgo_data {
const uint32_t NameSize;
const uint32_t NumCounters;
const uint64_t FuncHash;
const char *const Name;
const uint64_t *const Counters;
} __llvm_pgo_data;
/* TODO: void __llvm_pgo_get_size_for_buffer(void); */
/*!
* \brief Write instrumentation data to the given buffer.
*
* This function is currently broken: it shouldn't rely on libc, but it does.
* It should be changed to take a char* buffer, and write binary data directly
* to it.
*/
void __llvm_pgo_write_buffer(FILE *OutputFile);
const __llvm_pgo_data *__llvm_pgo_data_begin();
const __llvm_pgo_data *__llvm_pgo_data_end();
const char *__llvm_pgo_names_begin();
const char *__llvm_pgo_names_end();
const uint64_t *__llvm_pgo_counters_begin();
const uint64_t *__llvm_pgo_counters_end();