-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[PGO] Exposing PGO's Counter Reset and File Dumping APIs #76471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
6c9381e
Initial commit
a6c3b46
Frontend minor cleanup and adding a test
18ec4ac
Refactoring tests, adding profile-use macro
b741a55
Fix header comment
13a4bb3
Fix test case after header renaming.
cce25f0
Address review comments
ec47868
Adding a new test to cover weak symbols. Adding a new interface funct…
29086fc
Address code review
8e2bf69
Fixing documentation build error.
6f9a443
Adding missing line break in documentation.
ae9d57d
Address code review comments.
6a5d785
Fix failing test
7e48831
Adding documentation to advise using these APIs in a program's cold r…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/*===---- instr_prof_interface.h - Instrumentation PGO User Program API ----=== | ||
* | ||
* Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
* See https://llvm.org/LICENSE.txt for license information. | ||
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
* | ||
*===-----------------------------------------------------------------------=== | ||
* | ||
* This header provides a public interface for fine-grained control of counter | ||
* reset and profile dumping. These interface functions can be directly called | ||
* in user programs. | ||
* | ||
\*===---------------------------------------------------------------------===*/ | ||
|
||
#ifndef COMPILER_RT_INSTR_PROFILING | ||
#define COMPILER_RT_INSTR_PROFILING | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifdef __LLVM_INSTR_PROFILE_GENERATE | ||
// Profile file reset and dump interfaces. | ||
// When `-fprofile[-instr]-generate`/`-fcs-profile-generate` is in effect, | ||
// clang defines __LLVM_INSTR_PROFILE_GENERATE to pick up the API calls. | ||
|
||
/*! | ||
* \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. | ||
* | ||
* Note: There may be multiple copies of the profile runtime (one for each | ||
* instrumented image/DSO). This API only modifies the filename within the | ||
* copy of the runtime available to the calling image. | ||
* | ||
* Warning: This is a no-op if continuous mode (\ref | ||
* __llvm_profile_is_continuous_mode_enabled) is on. The reason for this is | ||
* that in continuous mode, profile counters are mmap()'d to the profile at | ||
* program initialization time. Support for transferring the mmap'd profile | ||
* counts to a new file has not been implemented. | ||
*/ | ||
void __llvm_profile_set_filename(const char *Name); | ||
|
||
/*! | ||
* \brief Interface to set all PGO counters to zero for the current process. | ||
* | ||
*/ | ||
void __llvm_profile_reset_counters(void); | ||
|
||
/*! | ||
* \brief this is a wrapper interface to \c __llvm_profile_write_file. | ||
* After this interface is invoked, an already dumped flag will be set | ||
* so that profile won't be dumped again during program exit. | ||
* Invocation of interface __llvm_profile_reset_counters will clear | ||
* the flag. This interface is designed to be used to collect profile | ||
* data from user selected hot regions. The use model is | ||
* __llvm_profile_reset_counters(); | ||
* ... hot region 1 | ||
* __llvm_profile_dump(); | ||
* .. some other code | ||
* __llvm_profile_reset_counters(); | ||
* ... hot region 2 | ||
* __llvm_profile_dump(); | ||
* | ||
* It is expected that on-line profile merging is on with \c %m specifier | ||
* used in profile filename . If merging is not turned on, user is expected | ||
* to invoke __llvm_profile_set_filename to specify different profile names | ||
* for different regions before dumping to avoid profile write clobbering. | ||
*/ | ||
int __llvm_profile_dump(void); | ||
|
||
// Interface to dump the current process' order file to disk. | ||
int __llvm_orderfile_dump(void); | ||
|
||
#else | ||
|
||
#define __llvm_profile_set_filename(Name) | ||
#define __llvm_profile_reset_counters() | ||
#define __llvm_profile_dump() (0) | ||
#define __llvm_orderfile_dump() (0) | ||
|
||
#endif | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.