[libc] Switch to using the generic `<gpuintrin.h>` implementations (#121810)
[llvm-project.git] / compiler-rt / include / profile / instr_prof_interface.h
blobbe40f2685934bea48d201d9edb8e0f5240a0b78d
1 /*===---- instr_prof_interface.h - Instrumentation PGO User Program API ----===
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-exception
7 *===-----------------------------------------------------------------------===
9 * This header provides a public interface for fine-grained control of counter
10 * reset and profile dumping. These interface functions can be directly called
11 * in user programs.
13 \*===---------------------------------------------------------------------===*/
15 #ifndef COMPILER_RT_INSTR_PROFILING
16 #define COMPILER_RT_INSTR_PROFILING
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
22 #ifdef __LLVM_INSTR_PROFILE_GENERATE
23 // 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.
27 /*!
28 * \brief Set the filename for writing instrumentation data.
30 * Sets the filename to be used for subsequent calls to
31 * \a __llvm_profile_write_file().
33 * \c Name is not copied, so it must remain valid. Passing NULL resets the
34 * filename logic to the default behaviour.
36 * Note: There may be multiple copies of the profile runtime (one for each
37 * instrumented image/DSO). This API only modifies the filename within the
38 * copy of the runtime available to the calling image.
40 * Warning: This is a no-op if continuous mode (\ref
41 * __llvm_profile_is_continuous_mode_enabled) is on. The reason for this is
42 * that in continuous mode, profile counters are mmap()'d to the profile at
43 * program initialization time. Support for transferring the mmap'd profile
44 * counts to a new file has not been implemented.
46 void __llvm_profile_set_filename(const char *Name);
48 /*!
49 * \brief Interface to set all PGO counters to zero for the current process.
52 void __llvm_profile_reset_counters(void);
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 set
57 * so that profile won't be dumped again during program exit.
58 * Invocation of interface __llvm_profile_reset_counters will clear
59 * the flag. This interface is designed to be used to collect profile
60 * data from user selected hot regions. The use model is
61 * __llvm_profile_reset_counters();
62 * ... hot region 1
63 * __llvm_profile_dump();
64 * .. some other code
65 * __llvm_profile_reset_counters();
66 * ... hot region 2
67 * __llvm_profile_dump();
69 * It is expected that on-line profile merging is on with \c %m specifier
70 * used in profile filename . If merging is not turned on, user is expected
71 * to invoke __llvm_profile_set_filename to specify different profile names
72 * for different regions before dumping to avoid profile write clobbering.
74 int __llvm_profile_dump(void);
76 // Interface to dump the current process' order file to disk.
77 int __llvm_orderfile_dump(void);
79 #else
81 #define __llvm_profile_set_filename(Name)
82 #define __llvm_profile_reset_counters()
83 #define __llvm_profile_dump() (0)
84 #define __llvm_orderfile_dump() (0)
86 #endif
88 #ifdef __cplusplus
89 } // extern "C"
90 #endif
92 #endif