LLVM 22.0.0git
|
A class that holds the constants that represent static data and their profile information and provides methods to operate on them. More...
#include "llvm/Analysis/StaticDataProfileInfo.h"
Public Types | |
enum class | StaticDataHotness : int8_t { Cold = -1 , LukewarmOrUnknown = 0 , Hot = 1 } |
Use signed enums for enum value comparison, and make 'LukewarmOrUnknown' as 0 so any accidentally uninitialized value will default to unknown. More... |
Public Member Functions | |
LLVM_ABI std::optional< uint64_t > | getConstantProfileCount (const Constant *C) const |
If C has a count, return it. Otherwise, return std::nullopt. | |
LLVM_ABI StaticDataHotness | getConstantHotnessUsingProfileCount (const Constant *C, const ProfileSummaryInfo *PSI, uint64_t Count) const |
Return the hotness of the constant C based on its profile count Count . | |
LLVM_ABI StaticDataHotness | getSectionHotnessUsingDataAccessProfile (std::optional< StringRef > SectionPrefix) const |
Return the hotness based on section prefix SectionPrefix . | |
LLVM_ABI StringRef | hotnessToStr (StaticDataHotness Hotness) const |
Return the string representation of the hotness enum Hotness . | |
StaticDataProfileInfo (bool EnableDataAccessProf) | |
LLVM_ABI void | addConstantProfileCount (const Constant *C, std::optional< uint64_t > Count) |
If Count is not nullopt, add it to the profile count of the constant C in a saturating way, and clamp the count to getInstrMaxCountValue if the result exceeds it. | |
LLVM_ABI StringRef | getConstantSectionPrefix (const Constant *C, const ProfileSummaryInfo *PSI) const |
Given a constant C , returns a section prefix. |
Public Attributes | |
DenseMap< const Constant *, uint64_t > | ConstantProfileCounts |
A constant is tracked only if the following conditions are met. | |
DenseSet< const Constant * > | ConstantWithoutCounts |
Keeps track of the constants that are seen at least once without profile counts. | |
bool | EnableDataAccessProf = false |
A class that holds the constants that represent static data and their profile information and provides methods to operate on them.
Definition at line 33 of file StaticDataProfileInfo.h.
|
strong |
Use signed enums for enum value comparison, and make 'LukewarmOrUnknown' as 0 so any accidentally uninitialized value will default to unknown.
Enumerator | |
---|---|
Cold | |
LukewarmOrUnknown | |
Hot |
Definition at line 52 of file StaticDataProfileInfo.h.
|
inline |
Definition at line 73 of file StaticDataProfileInfo.h.
References EnableDataAccessProf.
void StaticDataProfileInfo::addConstantProfileCount | ( | const Constant * | C, |
std::optional< uint64_t > | Count ) |
If Count
is not nullopt, add it to the profile count of the constant C
in a saturating way, and clamp the count to getInstrMaxCountValue
if the result exceeds it.
Otherwise, mark the constant as having no profile count.
Definition at line 53 of file StaticDataProfileInfo.cpp.
References llvm::CallingConv::C, ConstantProfileCounts, ConstantWithoutCounts, llvm::Count, llvm::getInstrMaxCountValue(), and llvm::SaturatingAdd().
StaticDataProfileInfo::StaticDataHotness StaticDataProfileInfo::getConstantHotnessUsingProfileCount | ( | const Constant * | C, |
const ProfileSummaryInfo * | PSI, | ||
uint64_t | Count ) const |
Return the hotness of the constant C
based on its profile count Count
.
Definition at line 68 of file StaticDataProfileInfo.cpp.
References llvm::CallingConv::C, Cold, ConstantWithoutCounts, llvm::Count, Hot, llvm::ProfileSummaryInfo::isColdCount(), llvm::ProfileSummaryInfo::isHotCount(), and LukewarmOrUnknown.
Referenced by getConstantSectionPrefix().
std::optional< uint64_t > StaticDataProfileInfo::getConstantProfileCount | ( | const Constant * | C | ) | const |
If C
has a count, return it. Otherwise, return std::nullopt.
Definition at line 109 of file StaticDataProfileInfo.cpp.
References llvm::CallingConv::C, ConstantProfileCounts, and I.
Referenced by getConstantSectionPrefix().
StringRef StaticDataProfileInfo::getConstantSectionPrefix | ( | const Constant * | C, |
const ProfileSummaryInfo * | PSI ) const |
Given a constant C
, returns a section prefix.
If C
is a global variable, the section prefix is the bigger one between its existing section prefix and its use profile count. Otherwise, the section prefix is based on its use profile count.
Definition at line 116 of file StaticDataProfileInfo.cpp.
References llvm::CallingConv::C, Cold, llvm::Count, llvm::dbgs(), llvm::dyn_cast(), EnableDataAccessProf, getConstantHotnessUsingProfileCount(), getConstantProfileCount(), getSectionHotnessUsingDataAccessProfile(), Hot, hotnessToStr(), llvm::memprof::IsAnnotationOK(), LLVM_DEBUG, and LukewarmOrUnknown.
StaticDataProfileInfo::StaticDataHotness StaticDataProfileInfo::getSectionHotnessUsingDataAccessProfile | ( | std::optional< StringRef > | SectionPrefix | ) | const |
Return the hotness based on section prefix SectionPrefix
.
Definition at line 87 of file StaticDataProfileInfo.cpp.
References assert(), Cold, Hot, and LukewarmOrUnknown.
Referenced by getConstantSectionPrefix().
StringRef StaticDataProfileInfo::hotnessToStr | ( | StaticDataHotness | Hotness | ) | const |
Return the string representation of the hotness enum Hotness
.
Definition at line 97 of file StaticDataProfileInfo.cpp.
Referenced by getConstantSectionPrefix().
A constant is tracked only if the following conditions are met.
1) It has local (i.e., private or internal) linkage.
Definition at line 40 of file StaticDataProfileInfo.h.
Referenced by addConstantProfileCount(), and getConstantProfileCount().
Keeps track of the constants that are seen at least once without profile counts.
Definition at line 44 of file StaticDataProfileInfo.h.
Referenced by addConstantProfileCount(), and getConstantHotnessUsingProfileCount().
bool llvm::StaticDataProfileInfo::EnableDataAccessProf = false |
Definition at line 70 of file StaticDataProfileInfo.h.
Referenced by getConstantSectionPrefix(), and StaticDataProfileInfo().