Path: blob/main/contrib/llvm-project/compiler-rt/include/profile/instr_prof_interface.h
35235 views
/*===---- instr_prof_interface.h - Instrumentation PGO User Program API ----===1*2* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3* See https://llvm.org/LICENSE.txt for license information.4* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5*6*===-----------------------------------------------------------------------===7*8* This header provides a public interface for fine-grained control of counter9* reset and profile dumping. These interface functions can be directly called10* in user programs.11*12\*===---------------------------------------------------------------------===*/1314#ifndef COMPILER_RT_INSTR_PROFILING15#define COMPILER_RT_INSTR_PROFILING1617#ifdef __cplusplus18extern "C" {19#endif2021#ifdef __LLVM_INSTR_PROFILE_GENERATE22// Profile file reset and dump interfaces.23// When `-fprofile[-instr]-generate`/`-fcs-profile-generate` is in effect,24// clang defines __LLVM_INSTR_PROFILE_GENERATE to pick up the API calls.2526/*!27* \brief Set the filename for writing instrumentation data.28*29* Sets the filename to be used for subsequent calls to30* \a __llvm_profile_write_file().31*32* \c Name is not copied, so it must remain valid. Passing NULL resets the33* filename logic to the default behaviour.34*35* Note: There may be multiple copies of the profile runtime (one for each36* instrumented image/DSO). This API only modifies the filename within the37* copy of the runtime available to the calling image.38*39* Warning: This is a no-op if continuous mode (\ref40* __llvm_profile_is_continuous_mode_enabled) is on. The reason for this is41* that in continuous mode, profile counters are mmap()'d to the profile at42* program initialization time. Support for transferring the mmap'd profile43* counts to a new file has not been implemented.44*/45void __llvm_profile_set_filename(const char *Name);4647/*!48* \brief Interface to set all PGO counters to zero for the current process.49*50*/51void __llvm_profile_reset_counters(void);5253/*!54* \brief this is a wrapper interface to \c __llvm_profile_write_file.55* After this interface is invoked, an already dumped flag will be set56* so that profile won't be dumped again during program exit.57* Invocation of interface __llvm_profile_reset_counters will clear58* the flag. This interface is designed to be used to collect profile59* data from user selected hot regions. The use model is60* __llvm_profile_reset_counters();61* ... hot region 162* __llvm_profile_dump();63* .. some other code64* __llvm_profile_reset_counters();65* ... hot region 266* __llvm_profile_dump();67*68* It is expected that on-line profile merging is on with \c %m specifier69* used in profile filename . If merging is not turned on, user is expected70* to invoke __llvm_profile_set_filename to specify different profile names71* for different regions before dumping to avoid profile write clobbering.72*/73int __llvm_profile_dump(void);7475// Interface to dump the current process' order file to disk.76int __llvm_orderfile_dump(void);7778#else7980#define __llvm_profile_set_filename(Name)81#define __llvm_profile_reset_counters()82#define __llvm_profile_dump() (0)83#define __llvm_orderfile_dump() (0)8485#endif8687#ifdef __cplusplus88} // extern "C"89#endif9091#endif929394