10#define DEBUG_TYPE "static-data-profile-info"
26 if (Attrs.hasAttribute(
"bss-section") || Attrs.hasAttribute(
"data-section") ||
27 Attrs.hasAttribute(
"relro-section") ||
28 Attrs.hasAttribute(
"rodata-section"))
39 if (Name.starts_with(
"llvm."))
88 std::optional<StringRef> MaybeSectionPrefix)
const {
89 if (!MaybeSectionPrefix)
92 assert((Prefix ==
"hot" || Prefix ==
"unlikely") &&
93 "Expect section_prefix to be one of hot or unlikely");
108std::optional<uint64_t>
121 auto DbgPrintPrefix = [](
StringRef Prefix) {
122 return Prefix.empty() ?
"<empty>" : Prefix;
131 !GV->getName().starts_with(
".str")) {
132 auto HotnessFromDataAccessProf =
138 << DbgPrintPrefix(Prefix)
139 <<
", solely from data access profiles\n");
150 }
else if (HotnessFromDataAccessProf ==
159 dbgs() << GV->getName() <<
" has section prefix "
160 << DbgPrintPrefix(Prefix)
161 <<
", the max from data access profiles as "
162 << DbgPrintPrefix(
hotnessToStr(HotnessFromDataAccessProf))
163 <<
" and PGO counters as "
164 << DbgPrintPrefix(
hotnessToStr(HotnessFromPGO)) <<
"\n");
174 bool EnableDataAccessProf =
false;
176 M.getModuleFlag(
"EnableDataAccessProf")))
177 EnableDataAccessProf = MD->getZExtValue();
188 "Static Data Profile Info",
false,
true)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Module.h This file contains the declarations for the Module class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This is an important base class in LLVM.
bool hasSection() const
Check if this global has a custom object file section.
bool isDeclarationForLinker() const
AttributeSet getAttributes() const
Return the attribute set for this global.
ImmutablePass class - This class is used to provide information that does not need to be run.
A Module instance is used to store all the information related to an LLVM module.
Analysis providing profile information.
LLVM_ABI bool isColdCount(uint64_t C) const
Returns true if count C is considered cold.
LLVM_ABI bool isHotCount(uint64_t C) const
Returns true if count C is considered hot.
This wraps the StaticDataProfileInfo object as an immutable pass, for a backend pass to operate on.
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
A class that holds the constants that represent static data and their profile information and provide...
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.
StaticDataHotness
Use signed enums for enum value comparison, and make 'LukewarmOrUnknown' as 0 so any accidentally uni...
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,...
LLVM_ABI StringRef getConstantSectionPrefix(const Constant *C, const ProfileSummaryInfo *PSI) const
Given a constant C, returns a section prefix.
LLVM_ABI StaticDataHotness getSectionHotnessUsingDataAccessProfile(std::optional< StringRef > SectionPrefix) const
Return the hotness based on section prefix SectionPrefix.
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.
StringRef - Represent a constant reference to a string, i.e.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
AnnotationKind getAnnotationKind(const GlobalVariable &GV)
Returns the annotation kind of the global variable GV.
bool IsAnnotationOK(const GlobalVariable &GV)
Returns true if the annotation kind of the global variable GV is AnnotationOK.
static bool hasExplicitSectionName(const GlobalVariable &GVar)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
uint64_t getInstrMaxCountValue()
Return the max count value. We reserver a few large values for special use.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionAddr VTableAddr Count
std::enable_if_t< std::is_unsigned_v< T >, T > SaturatingAdd(T X, T Y, bool *ResultOverflowed=nullptr)
Add two unsigned integers, X and Y, of type T.