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 StringRef | hotnessToStr (StaticDataHotness Hotness) const |
Return the string representation of the hotness enum Hotness . | |
StaticDataProfileInfo ()=default | |
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 |
Return a section prefix for the constant C based on its profile count. |
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. |
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.
|
default |
References llvm::CallingConv::C, llvm::Count, and LLVM_ABI.
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 49 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 64 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 94 of file StaticDataProfileInfo.cpp.
References llvm::CallingConv::C, ConstantProfileCounts, and I.
Referenced by getConstantSectionPrefix().
StringRef StaticDataProfileInfo::getConstantSectionPrefix | ( | const Constant * | C, |
const ProfileSummaryInfo * | PSI ) const |
Return a section prefix for the constant C
based on its profile count.
Definition at line 101 of file StaticDataProfileInfo.cpp.
References llvm::CallingConv::C, llvm::Count, getConstantHotnessUsingProfileCount(), getConstantProfileCount(), and hotnessToStr().
StringRef StaticDataProfileInfo::hotnessToStr | ( | StaticDataHotness | Hotness | ) | const |
Return the string representation of the hotness enum Hotness
.
Definition at line 82 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().