|
LLVM 24.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 (const AnalysisOptions &Opts, 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. | |
Static Public Member Functions | |
| static LLVM_ABI bool | shouldPreserveHotDataSectionPrefix (const LLVMContext &C) |
| Return -preserve-hot-data-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. | |
| const AnalysisOptions & | Opts |
| 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 41 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 60 of file StaticDataProfileInfo.h.
|
inline |
Definition at line 82 of file StaticDataProfileInfo.h.
References EnableDataAccessProf, and Opts.
| 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 65 of file StaticDataProfileInfo.cpp.
References 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 80 of file StaticDataProfileInfo.cpp.
References 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 121 of file StaticDataProfileInfo.cpp.
References 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 128 of file StaticDataProfileInfo.cpp.
References C(), Cold, llvm::Count, llvm::dbgs(), llvm::dyn_cast(), EnableDataAccessProf, getConstantHotnessUsingProfileCount(), getConstantProfileCount(), getSectionHotnessUsingDataAccessProfile(), Hot, hotnessToStr(), llvm::memprof::IsAnnotationOK(), LLVM_DEBUG, LukewarmOrUnknown, Opts, and starts_with().
Referenced by annotateModule().
| StaticDataProfileInfo::StaticDataHotness StaticDataProfileInfo::getSectionHotnessUsingDataAccessProfile | ( | std::optional< StringRef > | SectionPrefix | ) | const |
Return the hotness based on section prefix SectionPrefix.
Definition at line 99 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 109 of file StaticDataProfileInfo.cpp.
References Cold, Hot, and Opts.
Referenced by getConstantSectionPrefix().
|
static |
Return -preserve-hot-data-section-prefix.
Definition at line 16 of file StaticDataProfileInfo.cpp.
References C(), and llvm::getAnalysisOptions().
Referenced by getELFSectionNameForGlobal().
A constant is tracked only if the following conditions are met.
1) It has local (i.e., private or internal) linkage.
Definition at line 48 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 52 of file StaticDataProfileInfo.h.
Referenced by addConstantProfileCount(), and getConstantHotnessUsingProfileCount().
| bool llvm::StaticDataProfileInfo::EnableDataAccessProf = false |
Definition at line 79 of file StaticDataProfileInfo.h.
Referenced by getConstantSectionPrefix(), and StaticDataProfileInfo().
| const AnalysisOptions& llvm::StaticDataProfileInfo::Opts |
Definition at line 78 of file StaticDataProfileInfo.h.
Referenced by getConstantSectionPrefix(), hotnessToStr(), and StaticDataProfileInfo().