LLVM 22.0.0git
llvm::StaticDataProfileInfo Class Reference

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 Member Functions

LLVM_ABI std::optional< uint64_tgetConstantProfileCount (const Constant *C) const
 If C has a count, return it. Otherwise, return std::nullopt.
 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_tConstantProfileCounts
 Accummulate the profile count of a constant that will be lowered to static data sections.
DenseSet< const Constant * > ConstantWithoutCounts
 Keeps track of the constants that are seen at least once without profile counts.

Detailed Description

A class that holds the constants that represent static data and their profile information and provides methods to operate on them.

Definition at line 15 of file StaticDataProfileInfo.h.

Constructor & Destructor Documentation

◆ StaticDataProfileInfo()

llvm::StaticDataProfileInfo::StaticDataProfileInfo ( )
default

Member Function Documentation

◆ addConstantProfileCount()

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 9 of file StaticDataProfileInfo.cpp.

References llvm::CallingConv::C, ConstantProfileCounts, ConstantWithoutCounts, llvm::Count, llvm::getInstrMaxCountValue(), and llvm::SaturatingAdd().

◆ getConstantProfileCount()

std::optional< uint64_t > StaticDataProfileInfo::getConstantProfileCount ( const Constant * C) const

If C has a count, return it. Otherwise, return std::nullopt.

Definition at line 24 of file StaticDataProfileInfo.cpp.

References llvm::CallingConv::C, ConstantProfileCounts, and I.

Referenced by getConstantSectionPrefix().

◆ getConstantSectionPrefix()

StringRef StaticDataProfileInfo::getConstantSectionPrefix ( const Constant * C,
const ProfileSummaryInfo * PSI ) const

Return a section prefix for the constant C based on its profile count.

  • If a constant doesn't have a counter, return an empty string.
  • Otherwise,
    • If it has a hot count, return "hot".
    • If it is seen by unprofiled function, return an empty string.
    • If it has a cold count, return "unlikely".
    • Otherwise (e.g. it's used by lukewarm functions), return an empty string.

Definition at line 31 of file StaticDataProfileInfo.cpp.

References llvm::CallingConv::C, ConstantWithoutCounts, llvm::Count, getConstantProfileCount(), llvm::ProfileSummaryInfo::isColdCount(), and llvm::ProfileSummaryInfo::isHotCount().

Member Data Documentation

◆ ConstantProfileCounts

DenseMap<const Constant *, uint64_t> llvm::StaticDataProfileInfo::ConstantProfileCounts

Accummulate the profile count of a constant that will be lowered to static data sections.

Definition at line 19 of file StaticDataProfileInfo.h.

Referenced by addConstantProfileCount(), and getConstantProfileCount().

◆ ConstantWithoutCounts

DenseSet<const Constant *> llvm::StaticDataProfileInfo::ConstantWithoutCounts

Keeps track of the constants that are seen at least once without profile counts.

Definition at line 23 of file StaticDataProfileInfo.h.

Referenced by addConstantProfileCount(), and getConstantSectionPrefix().


The documentation for this class was generated from the following files: