10
10
#define PROFILE_INSTRPROFILING_H_
11
11
12
12
#include "InstrProfilingPort.h"
13
+ #include <stdio.h>
13
14
14
15
#define INSTR_PROF_VISIBILITY COMPILER_RT_VISIBILITY
15
16
#include "InstrProfData.inc"
@@ -37,6 +38,22 @@ typedef struct ValueProfNode {
37
38
#include "InstrProfData.inc"
38
39
} ValueProfNode ;
39
40
41
+ /*!
42
+ * \brief Return 1 if profile counters are continuously synced to the raw
43
+ * profile via an mmap(). This is in contrast to the default mode, in which
44
+ * the raw profile is written out at program exit time.
45
+ */
46
+ int __llvm_profile_is_continuous_mode_enabled (void );
47
+
48
+ /*!
49
+ * \brief Enable continuous mode.
50
+ *
51
+ * See \ref __llvm_profile_is_continuous_mode_enabled. The behavior is undefined
52
+ * if continuous mode is already enabled, or if it cannot be enable due to
53
+ * conflicting options.
54
+ */
55
+ void __llvm_profile_enable_continuous_mode (void );
56
+
40
57
/*!
41
58
* \brief Get number of bytes necessary to pad the argument to eight
42
59
* byte boundary.
@@ -125,7 +142,7 @@ int __llvm_orderfile_write_file(void);
125
142
/*!
126
143
* \brief this is a wrapper interface to \c __llvm_profile_write_file.
127
144
* After this interface is invoked, a arleady dumped flag will be set
128
- * so that profile won't be dumped again during program exit.
145
+ * so that profile won't be dumped again during program exit.
129
146
* Invocation of interface __llvm_profile_reset_counters will clear
130
147
* the flag. This interface is designed to be used to collect profile
131
148
* data from user selected hot regions. The use model is
@@ -154,9 +171,47 @@ int __llvm_orderfile_dump(void);
154
171
*
155
172
* \c Name is not copied, so it must remain valid. Passing NULL resets the
156
173
* filename logic to the default behaviour.
174
+ *
175
+ * Note: There may be multiple copies of the profile runtime (one for each
176
+ * instrumented image/DSO). This API only modifies the filename within the
177
+ * copy of the runtime available to the calling image.
178
+ *
179
+ * Warning: This is a no-op if continuous mode (\ref
180
+ * __llvm_profile_is_continuous_mode_enabled) is on. The reason for this is
181
+ * that in continuous mode, profile counters are mmap()'d to the profile at
182
+ * program initialization time. Support for transferring the mmap'd profile
183
+ * counts to a new file has not been implemented.
157
184
*/
158
185
void __llvm_profile_set_filename (const char * Name );
159
186
187
+ /*!
188
+ * \brief Set the FILE object for writing instrumentation data.
189
+ *
190
+ * Sets the FILE object to be used for subsequent calls to
191
+ * \a __llvm_profile_write_file(). The profile file name set by environment
192
+ * variable, command-line option, or calls to \a __llvm_profile_set_filename
193
+ * will be ignored.
194
+ *
195
+ * \c File will not be closed after a call to \a __llvm_profile_write_file() but
196
+ * it may be flushed. Passing NULL restores default behavior.
197
+ *
198
+ * If \c EnableMerge is nonzero, the runtime will always merge profiling data
199
+ * with the contents of the profiling file. If EnableMerge is zero, the runtime
200
+ * may still merge the data if it would have merged for another reason (for
201
+ * example, because of a %m specifier in the file name).
202
+ *
203
+ * Note: There may be multiple copies of the profile runtime (one for each
204
+ * instrumented image/DSO). This API only modifies the file object within the
205
+ * copy of the runtime available to the calling image.
206
+ *
207
+ * Warning: This is a no-op if continuous mode (\ref
208
+ * __llvm_profile_is_continuous_mode_enabled) is on. The reason for this is
209
+ * that in continuous mode, profile counters are mmap()'d to the profile at
210
+ * program initialization time. Support for transferring the mmap'd profile
211
+ * counts to a new file has not been implemented.
212
+ */
213
+ void __llvm_profile_set_file_object (FILE * File , int EnableMerge );
214
+
160
215
/*! \brief Register to write instrumentation data to file at exit. */
161
216
int __llvm_profile_register_write_file_atexit (void );
162
217
@@ -177,7 +232,12 @@ const char *__llvm_profile_get_path_prefix();
177
232
* \brief Return filename (including path) of the profile data. Note that if the
178
233
* user calls __llvm_profile_set_filename later after invoking this interface,
179
234
* the actual file name may differ from what is returned here.
180
- * Side-effect: this API call will invoke malloc with dynamic memory allocation.
235
+ * Side-effect: this API call will invoke malloc with dynamic memory allocation
236
+ * (the returned pointer must be passed to `free` to avoid a leak).
237
+ *
238
+ * Note: There may be multiple copies of the profile runtime (one for each
239
+ * instrumented image/DSO). This API only retrieves the filename from the copy
240
+ * of the runtime available to the calling image.
181
241
*/
182
242
const char * __llvm_profile_get_filename ();
183
243
@@ -191,6 +251,24 @@ uint64_t __llvm_profile_get_version(void);
191
251
uint64_t __llvm_profile_get_data_size (const __llvm_profile_data * Begin ,
192
252
const __llvm_profile_data * End );
193
253
254
+ /* ! \brief Given the sizes of the data and counter information, return the
255
+ * number of padding bytes before and after the counters, and after the names,
256
+ * in the raw profile.
257
+ *
258
+ * Note: In this context, "size" means "number of entries", i.e. the first two
259
+ * arguments must be the result of __llvm_profile_get_data_size() and of
260
+ * (__llvm_profile_end_counters() - __llvm_profile_begin_counters()) resp.
261
+ *
262
+ * Note: When mmap() mode is disabled, no padding bytes before/after counters
263
+ * are needed. However, in mmap() mode, the counter section in the raw profile
264
+ * must be page-aligned: this API computes the number of padding bytes
265
+ * needed to achieve that.
266
+ */
267
+ void __llvm_profile_get_padding_sizes_for_counters (
268
+ uint64_t DataSize , uint64_t CountersSize , uint64_t NamesSize ,
269
+ uint64_t * PaddingBytesBeforeCounters , uint64_t * PaddingBytesAfterCounters ,
270
+ uint64_t * PaddingBytesAfterNames );
271
+
194
272
/*!
195
273
* \brief Set the flag that profile data has been dumped to the file.
196
274
* This is useful for users to disable dumping profile data to the file for
0 commit comments