brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 678cea0 Raw
89 lines · c
1/*===---- instr_prof_interface.h - Instrumentation PGO User Program API ----===2 *3 * Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4 * See https://llvm.org/LICENSE.txt for license information.5 * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6 *7 *===-----------------------------------------------------------------------===8 *9 * This header provides a public interface for fine-grained control of counter10 * reset and profile dumping. These interface functions can be directly called11 * in user programs.12 *13\*===---------------------------------------------------------------------===*/14 15#ifndef COMPILER_RT_INSTR_PROFILING16#define COMPILER_RT_INSTR_PROFILING17 18#ifdef __cplusplus19extern "C" {20#endif21 22#ifdef __LLVM_INSTR_PROFILE_GENERATE23// Profile file reset and dump interfaces.24// When `-fprofile[-instr]-generate`/`-fcs-profile-generate` is in effect,25// clang defines __LLVM_INSTR_PROFILE_GENERATE to pick up the API calls.26 27/*!28 * \brief Set the filename for writing instrumentation data.29 *30 * Sets the filename to be used for subsequent calls to31 * \a __llvm_profile_write_file().32 *33 * \c Name is not copied, so it must remain valid.  Passing NULL resets the34 * filename logic to the default behaviour.35 *36 * Note: There may be multiple copies of the profile runtime (one for each37 * instrumented image/DSO). This API only modifies the filename within the38 * copy of the runtime available to the calling image.39 *40 * Warning: This is a no-op if continuous mode (\ref41 * __llvm_profile_is_continuous_mode_enabled) is on. The reason for this is42 * that in continuous mode, profile counters are mmap()'d to the profile at43 * program initialization time. Support for transferring the mmap'd profile44 * counts to a new file has not been implemented.45 */46void __llvm_profile_set_filename(const char *Name);47 48/*!49 * \brief Interface to set all PGO counters to zero for the current process.50 *51 */52void __llvm_profile_reset_counters(void);53 54/*!55 * \brief this is a wrapper interface to \c __llvm_profile_write_file.56 * After this interface is invoked, an already dumped flag will be set57 * so that profile won't be dumped again during program exit.58 * Invocation of interface __llvm_profile_reset_counters will clear59 * the flag. This interface is designed to be used to collect profile60 * data from user selected hot regions. The use model is61 *      __llvm_profile_reset_counters();62 *      ... hot region 163 *      __llvm_profile_dump();64 *      .. some other code65 *      __llvm_profile_reset_counters();66 *      ... hot region 267 *      __llvm_profile_dump();68 *69 *  It is expected that on-line profile merging is on with \c %m specifier70 *  used in profile filename . If merging is not turned on, user is expected71 *  to invoke __llvm_profile_set_filename to specify different profile names72 *  for different regions before dumping to avoid profile write clobbering.73 */74int __llvm_profile_dump(void);75 76#else77 78#define __llvm_profile_set_filename(Name)79#define __llvm_profile_reset_counters()80#define __llvm_profile_dump() (0)81 82#endif83 84#ifdef __cplusplus85} // extern "C"86#endif87 88#endif89