diff options
author | Teresa Johnson <tejohnson@google.com> | 2023-07-10 08:47:20 -0700 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2023-07-10 16:42:56 -0700 |
commit | b4a82b62258c5f650a1cccf5b179933e6bae4867 (patch) | |
tree | a7b11bdac5cb2ec541b9f9be58ca5a8957115d28 /llvm/lib/Support/PGOOptions.cpp | |
parent | 5f6c55836fb4666f3160400dc273deefdac82e06 (diff) | |
download | llvm-b4a82b62258c5f650a1cccf5b179933e6bae4867.zip llvm-b4a82b62258c5f650a1cccf5b179933e6bae4867.tar.gz llvm-b4a82b62258c5f650a1cccf5b179933e6bae4867.tar.bz2 |
[MemProf] Use new option/pass for profile feedback and matching
Previously the MemProf profile was expected to be in the same profile
file as a normal PGO profile, passed via the usual -fprofile-use=
option, and was matched in the same pass. To simplify profile
preparation, since the raw MemProf profile requires the binary for
symbolization and may be simpler to index separately from the raw PGO
profile, and also to enable providing a MemProf profile for a SamplePGO
build, separate out the MemProf feedback option and matching pass.
This patch adds the -fmemory-profile-use=${file} option, and the
provided file is passed down to LLVM and ultimately used in a new
MemProfUsePass which performs the matching of just the memory profile
contents of that file.
Note that a single profile file containing both normal PGO and MemProf
profile data is still supported, and the relevant profile data is
matched by the appropriate matching pass(es) based on which option(s)
the profile is provided with (the same profile file can be supplied to
both feedback options).
Differential Revision: https://reviews.llvm.org/D154856
Diffstat (limited to 'llvm/lib/Support/PGOOptions.cpp')
-rw-r--r-- | llvm/lib/Support/PGOOptions.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/llvm/lib/Support/PGOOptions.cpp b/llvm/lib/Support/PGOOptions.cpp index d11528c..04d50cc 100644 --- a/llvm/lib/Support/PGOOptions.cpp +++ b/llvm/lib/Support/PGOOptions.cpp @@ -13,12 +13,13 @@ using namespace llvm; PGOOptions::PGOOptions(std::string ProfileFile, std::string CSProfileGenFile, std::string ProfileRemappingFile, + std::string MemoryProfile, IntrusiveRefCntPtr<vfs::FileSystem> FS, PGOAction Action, CSPGOAction CSAction, bool DebugInfoForProfiling, bool PseudoProbeForProfiling) : ProfileFile(ProfileFile), CSProfileGenFile(CSProfileGenFile), - ProfileRemappingFile(ProfileRemappingFile), Action(Action), - CSAction(CSAction), + ProfileRemappingFile(ProfileRemappingFile), MemoryProfile(MemoryProfile), + Action(Action), CSAction(CSAction), DebugInfoForProfiling(DebugInfoForProfiling || (Action == SampleUse && !PseudoProbeForProfiling)), PseudoProbeForProfiling(PseudoProbeForProfiling), FS(std::move(FS)) { @@ -36,13 +37,18 @@ PGOOptions::PGOOptions(std::string ProfileFile, std::string CSProfileGenFile, // a profile. assert(this->CSAction != CSIRUse || this->Action == IRUse); - // If neither Action nor CSAction, DebugInfoForProfiling or - // PseudoProbeForProfiling needs to be true. + // Cannot optimize with MemProf profile during IR instrumentation. + assert(this->MemoryProfile.empty() || this->Action != PGOOptions::IRInstr); + + // If neither Action nor CSAction nor MemoryProfile are set, + // DebugInfoForProfiling or PseudoProbeForProfiling needs to be true. assert(this->Action != NoAction || this->CSAction != NoCSAction || - this->DebugInfoForProfiling || this->PseudoProbeForProfiling); + !this->MemoryProfile.empty() || this->DebugInfoForProfiling || + this->PseudoProbeForProfiling); // If we need to use the profile, the VFS cannot be nullptr. - assert(this->FS || !(this->Action == IRUse || this->CSAction == CSIRUse)); + assert(this->FS || !(this->Action == IRUse || this->CSAction == CSIRUse || + !this->MemoryProfile.empty())); } PGOOptions::PGOOptions(const PGOOptions &) = default; |