2014-03-20 06:10:27 +08:00
|
|
|
/*===- 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.
|
|
|
|
|*
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
2014-03-22 02:47:23 +08:00
|
|
|
#ifndef PROFILE_INSTRPROFILING_H_
|
|
|
|
#define PROFILE_INSTRPROFILING_H_
|
2014-03-22 02:29:15 +08:00
|
|
|
|
2015-12-11 02:17:01 +08:00
|
|
|
#include "InstrProfilingPort.h"
|
2015-11-24 01:09:40 +08:00
|
|
|
#include "InstrProfData.inc"
|
|
|
|
|
2015-11-21 03:41:02 +08:00
|
|
|
enum ValueKind {
|
2015-11-24 01:43:10 +08:00
|
|
|
#define VALUE_PROF_KIND(Enumerator, Value) Enumerator = Value,
|
|
|
|
#include "InstrProfData.inc"
|
2015-11-21 03:41:02 +08:00
|
|
|
};
|
2015-11-19 02:12:35 +08:00
|
|
|
|
2015-11-21 03:41:02 +08:00
|
|
|
typedef void *IntPtrT;
|
2015-12-16 11:29:15 +08:00
|
|
|
typedef struct COMPILER_RT_ALIGNAS(INSTR_PROF_DATA_ALIGNMENT)
|
|
|
|
__llvm_profile_data {
|
2015-11-24 01:50:53 +08:00
|
|
|
#define INSTR_PROF_DATA(Type, LLVMType, Name, Initializer) Type Name;
|
|
|
|
#include "InstrProfData.inc"
|
2014-03-21 04:00:44 +08:00
|
|
|
} __llvm_profile_data;
|
2014-03-20 06:10:27 +08:00
|
|
|
|
2015-10-17 06:21:56 +08:00
|
|
|
typedef struct __llvm_profile_header {
|
2015-11-24 02:36:40 +08:00
|
|
|
#define INSTR_PROF_RAW_HEADER(Type, Name, Initializer) Type Name;
|
|
|
|
#include "InstrProfData.inc"
|
2015-10-17 06:21:56 +08:00
|
|
|
} __llvm_profile_header;
|
|
|
|
|
2015-11-19 02:12:35 +08:00
|
|
|
/*!
|
|
|
|
* \brief Get number of bytes necessary to pad the argument to eight
|
|
|
|
* byte boundary.
|
|
|
|
*/
|
|
|
|
uint8_t __llvm_profile_get_num_padding_bytes(uint64_t SizeInBytes);
|
2015-10-17 06:21:56 +08:00
|
|
|
|
2014-03-22 02:29:19 +08:00
|
|
|
/*!
|
|
|
|
* \brief Get required size for profile buffer.
|
|
|
|
*/
|
|
|
|
uint64_t __llvm_profile_get_size_for_buffer(void);
|
2014-03-20 06:10:27 +08:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Write instrumentation data to the given buffer.
|
|
|
|
*
|
2014-03-22 02:29:19 +08:00
|
|
|
* \pre \c Buffer is the start of a buffer at least as big as \a
|
|
|
|
* __llvm_profile_get_size_for_buffer().
|
2014-03-20 06:10:27 +08:00
|
|
|
*/
|
2014-03-22 02:29:19 +08:00
|
|
|
int __llvm_profile_write_buffer(char *Buffer);
|
2014-03-21 04:00:44 +08:00
|
|
|
|
2014-09-04 23:45:31 +08:00
|
|
|
const __llvm_profile_data *__llvm_profile_begin_data(void);
|
|
|
|
const __llvm_profile_data *__llvm_profile_end_data(void);
|
|
|
|
const char *__llvm_profile_begin_names(void);
|
|
|
|
const char *__llvm_profile_end_names(void);
|
|
|
|
uint64_t *__llvm_profile_begin_counters(void);
|
|
|
|
uint64_t *__llvm_profile_end_counters(void);
|
2014-03-22 02:29:15 +08:00
|
|
|
|
2015-11-19 05:54:40 +08:00
|
|
|
/*!
|
|
|
|
* \brief Clear profile counters to zero.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
void __llvm_profile_reset_counters(void);
|
|
|
|
|
2015-11-19 02:12:35 +08:00
|
|
|
/*!
|
|
|
|
* \brief Counts the number of times a target value is seen.
|
|
|
|
*
|
|
|
|
* Records the target value for the CounterIndex if not seen before. Otherwise,
|
|
|
|
* increments the counter associated w/ the target value.
|
2015-11-24 04:07:09 +08:00
|
|
|
* void __llvm_profile_instrument_target(uint64_t TargetValue, void *Data,
|
|
|
|
* uint32_t CounterIndex);
|
2015-11-19 02:12:35 +08:00
|
|
|
*/
|
2015-11-24 04:07:09 +08:00
|
|
|
void INSTR_PROF_VALUE_PROF_FUNC(
|
|
|
|
#define VALUE_PROF_FUNC_PARAM(ArgType, ArgName, ArgLLVMType) ArgType ArgName
|
|
|
|
#include "InstrProfData.inc"
|
|
|
|
);
|
2015-11-19 02:12:35 +08:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Prepares the value profiling data for output.
|
|
|
|
*
|
|
|
|
* Prepares a single __llvm_profile_value_data array out of the many
|
2015-11-21 03:41:02 +08:00
|
|
|
* ValueProfNode trees (one per instrumented function).
|
2015-11-19 02:12:35 +08:00
|
|
|
*/
|
|
|
|
uint64_t __llvm_profile_gather_value_data(uint8_t **DataArray);
|
|
|
|
|
2014-03-22 02:29:15 +08:00
|
|
|
/*!
|
|
|
|
* \brief Write instrumentation data to the current file.
|
|
|
|
*
|
|
|
|
* Writes to the file with the last name given to \a __llvm_profile_set_filename(),
|
|
|
|
* or if it hasn't been called, the \c LLVM_PROFILE_FILE environment variable,
|
2015-04-29 06:54:51 +08:00
|
|
|
* or if that's not set, the last name given to
|
|
|
|
* \a __llvm_profile_override_default_filename(), or if that's not set,
|
2015-07-10 01:21:52 +08:00
|
|
|
* \c "default.profraw".
|
2014-03-22 02:29:15 +08:00
|
|
|
*/
|
|
|
|
int __llvm_profile_write_file(void);
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Set the filename for writing instrumentation data.
|
|
|
|
*
|
|
|
|
* Sets the filename to be used for subsequent calls to
|
|
|
|
* \a __llvm_profile_write_file().
|
|
|
|
*
|
|
|
|
* \c Name is not copied, so it must remain valid. Passing NULL resets the
|
|
|
|
* filename logic to the default behaviour.
|
|
|
|
*/
|
|
|
|
void __llvm_profile_set_filename(const char *Name);
|
|
|
|
|
2015-04-29 06:54:51 +08:00
|
|
|
/*!
|
|
|
|
* \brief Set the filename for writing instrumentation data, unless the
|
|
|
|
* \c LLVM_PROFILE_FILE environment variable was set.
|
|
|
|
*
|
|
|
|
* Unless overridden, sets the filename to be used for subsequent calls to
|
|
|
|
* \a __llvm_profile_write_file().
|
|
|
|
*
|
|
|
|
* \c Name is not copied, so it must remain valid. Passing NULL resets the
|
|
|
|
* filename logic to the default behaviour (unless the \c LLVM_PROFILE_FILE
|
|
|
|
* was set in which case it has no effect).
|
|
|
|
*/
|
|
|
|
void __llvm_profile_override_default_filename(const char *Name);
|
|
|
|
|
2014-03-22 02:29:15 +08:00
|
|
|
/*! \brief Register to write instrumentation data to file at exit. */
|
|
|
|
int __llvm_profile_register_write_file_atexit(void);
|
|
|
|
|
2014-05-17 09:27:30 +08:00
|
|
|
/*! \brief Initialize file handling. */
|
|
|
|
void __llvm_profile_initialize_file(void);
|
2014-05-16 09:30:24 +08:00
|
|
|
|
2014-03-22 02:29:15 +08:00
|
|
|
/*! \brief Get the magic token for the file format. */
|
|
|
|
uint64_t __llvm_profile_get_magic(void);
|
|
|
|
|
|
|
|
/*! \brief Get the version of the file format. */
|
|
|
|
uint64_t __llvm_profile_get_version(void);
|
|
|
|
|
2014-03-22 02:47:23 +08:00
|
|
|
#endif /* PROFILE_INSTRPROFILING_H_ */
|