LLVM 20.0.0git
Classes | Typedefs | Enumerations | Functions | Variables
llvm::sampleprof Namespace Reference

Classes

class  DefaultFunctionPruningStrategy
 
class  FunctionId
 This class represents a function that is read from a sample profile. More...
 
class  FunctionPruningStrategy
 When writing a profile with size limit, user may want to use a different strategy to reduce function count other than dropping functions with fewest samples first. More...
 
class  FunctionSamples
 Representation of the samples collected for a function. More...
 
class  HashKeyMap
 This class is a wrapper to associative container MapT<KeyT, ValueT> using the hash value of the original key as the new key. More...
 
struct  LineLocation
 Represents the relative location of an instruction. More...
 
struct  LineLocationHash
 
class  ProfileConverter
 Helper class for profile conversion. More...
 
class  ProfiledCallGraph
 
struct  ProfiledCallGraphEdge
 
struct  ProfiledCallGraphNode
 
class  ProfileSymbolList
 ProfileSymbolList records the list of function symbols shown up in the binary used to generate the profile. More...
 
class  SampleContext
 
struct  SampleContextFrame
 
struct  SampleContextFrameHash
 
class  SampleContextTrimmer
 SampleContextTrimmer impelements helper functions to trim, merge cold context profiles. More...
 
class  SampleProfileMap
 This class provides operator overloads to the map container using MD5 as the key type, so that existing code can still work in most cases using SampleContext as key. More...
 
class  SampleProfileReader
 Sample-based profile reader. More...
 
class  SampleProfileReaderBinary
 
class  SampleProfileReaderExtBinary
 
class  SampleProfileReaderExtBinaryBase
 SampleProfileReaderExtBinaryBase/SampleProfileWriterExtBinaryBase defines the basic structure of the extensible binary format. More...
 
class  SampleProfileReaderGCC
 
class  SampleProfileReaderItaniumRemapper
 SampleProfileReaderItaniumRemapper remaps the profile data from a sample profile data reader, by applying a provided set of equivalences between components of the symbol names in the profile. More...
 
class  SampleProfileReaderRawBinary
 
class  SampleProfileReaderText
 
class  SampleProfileWriter
 Sample-based profile writer. Base class. More...
 
class  SampleProfileWriterBinary
 Sample-based profile writer (binary format). More...
 
class  SampleProfileWriterExtBinary
 
class  SampleProfileWriterExtBinaryBase
 
class  SampleProfileWriterRawBinary
 
class  SampleProfileWriterText
 Sample-based profile writer (text format). More...
 
class  SampleRecord
 Representation of a single sample record. More...
 
class  SampleSorter
 Sort a LocationT->SampleT map by LocationT. More...
 
struct  SecHdrTableEntry
 

Typedefs

using SampleContextFrameVector = SmallVector< SampleContextFrame, 1 >
 
using SampleContextFrames = ArrayRef< SampleContextFrame >
 
using BodySampleMap = std::map< LineLocation, SampleRecord >
 
using FunctionSamplesMap = std::map< FunctionId, FunctionSamples >
 
using CallsiteSampleMap = std::map< LineLocation, FunctionSamplesMap >
 
using LocToLocMap = std::unordered_map< LineLocation, LineLocation, LineLocationHash >
 
using NameFunctionSamples = std::pair< hash_code, const FunctionSamples * >
 
using InlineCallStack = SmallVector< FunctionSamples *, 10 >
 

Enumerations

enum  SampleProfileFormat {
  SPF_None = 0 , SPF_Text = 0x1 , SPF_Compact_Binary = 0x2 , SPF_GCC = 0x3 ,
  SPF_Ext_Binary = 0x4 , SPF_Binary = 0xff
}
 
enum  SampleProfileLayout { SPL_None = 0 , SPL_Nest = 0x1 , SPL_Flat = 0x2 }
 
enum  SecType {
  SecInValid = 0 , SecProfSummary = 1 , SecNameTable = 2 , SecProfileSymbolList = 3 ,
  SecFuncOffsetTable = 4 , SecFuncMetadata = 5 , SecCSNameTable = 6 , SecFuncProfileFirst = 32 ,
  SecLBRProfile = SecFuncProfileFirst
}
 
enum class  SecCommonFlags : uint32_t { SecFlagInValid = 0 , SecFlagCompress = (1 << 0) , SecFlagFlat = (1 << 1) }
 
enum class  SecNameTableFlags : uint32_t { SecFlagInValid = 0 , SecFlagMD5Name = (1 << 0) , SecFlagFixedLengthMD5 = (1 << 1) , SecFlagUniqSuffix = (1 << 2) }
 
enum class  SecProfSummaryFlags : uint32_t {
  SecFlagInValid = 0 , SecFlagPartial = (1 << 0) , SecFlagFullContext = (1 << 1) , SecFlagFSDiscriminator = (1 << 2) ,
  SecFlagIsPreInlined = (1 << 4)
}
 
enum class  SecFuncMetadataFlags : uint32_t { SecFlagInvalid = 0 , SecFlagIsProbeBased = (1 << 0) , SecFlagHasAttribute = (1 << 1) }
 
enum class  SecFuncOffsetFlags : uint32_t { SecFlagInvalid = 0 , SecFlagOrdered = (1 << 0) }
 
enum  ContextStateMask {
  UnknownContext = 0x0 , RawContext = 0x1 , SyntheticContext = 0x2 , InlinedContext = 0x4 ,
  MergedContext = 0x8
}
 
enum  ContextAttributeMask { ContextNone = 0x0 , ContextWasInlined = 0x1 , ContextShouldBeInlined = 0x2 , ContextDuplicatedIntoBase }
 
enum  HistType {
  HIST_TYPE_INTERVAL , HIST_TYPE_POW2 , HIST_TYPE_SINGLE_VALUE , HIST_TYPE_CONST_DELTA ,
  HIST_TYPE_INDIR_CALL , HIST_TYPE_AVERAGE , HIST_TYPE_IOR , HIST_TYPE_INDIR_CALL_TOPN
}
 
enum  SectionLayout { DefaultLayout , CtxSplitLayout , NumOfLayout }
 
enum  FSDiscriminatorPass {
  Base = 0 , Pass0 = 0 , Pass1 = 1 , Pass2 = 2 ,
  Pass3 = 3 , Pass4 = 4 , PassLast = 4
}
 

Functions

bool operator== (const FunctionId &LHS, const FunctionId &RHS)
 
bool operator!= (const FunctionId &LHS, const FunctionId &RHS)
 
bool operator< (const FunctionId &LHS, const FunctionId &RHS)
 
bool operator<= (const FunctionId &LHS, const FunctionId &RHS)
 
bool operator> (const FunctionId &LHS, const FunctionId &RHS)
 
bool operator>= (const FunctionId &LHS, const FunctionId &RHS)
 
raw_ostreamoperator<< (raw_ostream &OS, const FunctionId &Obj)
 
uint64_t MD5Hash (const FunctionId &Obj)
 
uint64_t hash_value (const FunctionId &Obj)
 
static uint64_t SPMagic (SampleProfileFormat Format=SPF_Binary)
 
static uint64_t SPVersion ()
 
static std::string getSecName (SecType Type)
 
template<class SecFlagType >
static void verifySecFlag (SecType Type, SecFlagType Flag)
 
template<class SecFlagType >
static void addSecFlag (SecHdrTableEntry &Entry, SecFlagType Flag)
 
template<class SecFlagType >
static void removeSecFlag (SecHdrTableEntry &Entry, SecFlagType Flag)
 
template<class SecFlagType >
static bool hasSecFlag (const SecHdrTableEntry &Entry, SecFlagType Flag)
 
raw_ostreamoperator<< (raw_ostream &OS, const LineLocation &Loc)
 
raw_ostreamoperator<< (raw_ostream &OS, const SampleRecord &Sample)
 
static hash_code hash_value (const SampleContextFrame &arg)
 
static hash_code hash_value (const SampleContext &Context)
 
raw_ostreamoperator<< (raw_ostream &OS, const SampleContext &Context)
 
static FunctionId getRepInFormat (StringRef Name)
 Get the proper representation of a string according to whether the current Format uses MD5 to represent the string.
 
raw_ostreamoperator<< (raw_ostream &OS, const FunctionSamples &FS)
 
void sortFuncProfiles (const SampleProfileMap &ProfileMap, std::vector< NameFunctionSamples > &SortedProfiles)
 

Variables

const std::array< SmallVector< SecHdrTableEntry, 8 >, NumOfLayoutExtBinaryHdrLayoutTable
 

Typedef Documentation

◆ BodySampleMap

Definition at line 732 of file SampleProf.h.

◆ CallsiteSampleMap

Definition at line 736 of file SampleProf.h.

◆ FunctionSamplesMap

Definition at line 735 of file SampleProf.h.

◆ InlineCallStack

Definition at line 804 of file SampleProfReader.h.

◆ LocToLocMap

Definition at line 737 of file SampleProf.h.

◆ NameFunctionSamples

Definition at line 1344 of file SampleProf.h.

◆ SampleContextFrames

Definition at line 505 of file SampleProf.h.

◆ SampleContextFrameVector

Definition at line 504 of file SampleProf.h.

Enumeration Type Documentation

◆ ContextAttributeMask

Enumerator
ContextNone 
ContextWasInlined 
ContextShouldBeInlined 
ContextDuplicatedIntoBase 

Definition at line 456 of file SampleProf.h.

◆ ContextStateMask

Enumerator
UnknownContext 
RawContext 
SyntheticContext 
InlinedContext 
MergedContext 

Definition at line 447 of file SampleProf.h.

◆ FSDiscriminatorPass

Enumerator
Base 
Pass0 
Pass1 
Pass2 
Pass3 
Pass4 
PassLast 

Definition at line 57 of file Discriminator.h.

◆ HistType

Enumerator
HIST_TYPE_INTERVAL 
HIST_TYPE_POW2 
HIST_TYPE_SINGLE_VALUE 
HIST_TYPE_CONST_DELTA 
HIST_TYPE_INDIR_CALL 
HIST_TYPE_AVERAGE 
HIST_TYPE_IOR 
HIST_TYPE_INDIR_CALL_TOPN 

Definition at line 808 of file SampleProfReader.h.

◆ SampleProfileFormat

Enumerator
SPF_None 
SPF_Text 
SPF_Compact_Binary 
SPF_GCC 
SPF_Ext_Binary 
SPF_Binary 

Definition at line 91 of file SampleProf.h.

◆ SampleProfileLayout

Enumerator
SPL_None 
SPL_Nest 
SPL_Flat 

Definition at line 100 of file SampleProf.h.

◆ SecCommonFlags

Enumerator
SecFlagInValid 
SecFlagCompress 
SecFlagFlat 

Definition at line 169 of file SampleProf.h.

◆ SecFuncMetadataFlags

Enumerator
SecFlagInvalid 
SecFlagIsProbeBased 
SecFlagHasAttribute 

Definition at line 206 of file SampleProf.h.

◆ SecFuncOffsetFlags

Enumerator
SecFlagInvalid 
SecFlagOrdered 

Definition at line 212 of file SampleProf.h.

◆ SecNameTableFlags

Enumerator
SecFlagInValid 
SecFlagMD5Name 
SecFlagFixedLengthMD5 
SecFlagUniqSuffix 

Definition at line 179 of file SampleProf.h.

◆ SecProfSummaryFlags

Enumerator
SecFlagInValid 
SecFlagPartial 

SecFlagPartial means the profile is for common/shared code.

The common profile is usually merged from profiles collected from running other targets.

SecFlagFullContext 

SecFlagContext means this is context-sensitive flat profile for CSSPGO.

SecFlagFSDiscriminator 

SecFlagFSDiscriminator means this profile uses flow-sensitive discriminators.

SecFlagIsPreInlined 

SecFlagIsPreInlined means this profile contains ShouldBeInlined contexts thus this is CS preinliner computed.

Definition at line 189 of file SampleProf.h.

◆ SectionLayout

Enumerator
DefaultLayout 
CtxSplitLayout 
NumOfLayout 

Definition at line 29 of file SampleProfWriter.h.

◆ SecType

Enumerator
SecInValid 
SecProfSummary 
SecNameTable 
SecProfileSymbolList 
SecFuncOffsetTable 
SecFuncMetadata 
SecCSNameTable 
SecFuncProfileFirst 
SecLBRProfile 

Definition at line 118 of file SampleProf.h.

Function Documentation

◆ addSecFlag()

template<class SecFlagType >
static void llvm::sampleprof::addSecFlag ( SecHdrTableEntry Entry,
SecFlagType  Flag 
)
inlinestatic

◆ getRepInFormat()

static FunctionId llvm::sampleprof::getRepInFormat ( StringRef  Name)
inlinestatic

◆ getSecName()

static std::string llvm::sampleprof::getSecName ( SecType  Type)
inlinestatic

◆ hash_value() [1/3]

uint64_t llvm::sampleprof::hash_value ( const FunctionId Obj)
inline

◆ hash_value() [2/3]

static hash_code llvm::sampleprof::hash_value ( const SampleContext Context)
inlinestatic

Definition at line 721 of file SampleProf.h.

References llvm::sampleprof::SampleContext::getHashCode().

◆ hash_value() [3/3]

static hash_code llvm::sampleprof::hash_value ( const SampleContextFrame arg)
inlinestatic

Definition at line 500 of file SampleProf.h.

References llvm::sampleprof::SampleContextFrame::getHashCode().

◆ hasSecFlag()

template<class SecFlagType >
static bool llvm::sampleprof::hasSecFlag ( const SecHdrTableEntry Entry,
SecFlagType  Flag 
)
inlinestatic

◆ MD5Hash()

uint64_t llvm::sampleprof::MD5Hash ( const FunctionId Obj)
inline

◆ operator!=()

bool llvm::sampleprof::operator!= ( const FunctionId LHS,
const FunctionId RHS 
)
inline

Definition at line 139 of file FunctionId.h.

References LHS, and RHS.

◆ operator<()

bool llvm::sampleprof::operator< ( const FunctionId LHS,
const FunctionId RHS 
)
inline

Definition at line 143 of file FunctionId.h.

References LHS, and RHS.

◆ operator<<() [1/5]

raw_ostream & llvm::sampleprof::operator<< ( raw_ostream OS,
const FunctionId Obj 
)
inline

Definition at line 159 of file FunctionId.h.

◆ operator<<() [2/5]

raw_ostream & llvm::sampleprof::operator<< ( raw_ostream OS,
const FunctionSamples FS 
)

Definition at line 196 of file SampleProf.cpp.

References OS.

◆ operator<<() [3/5]

raw_ostream & llvm::sampleprof::operator<< ( raw_ostream OS,
const LineLocation Loc 
)

Definition at line 111 of file SampleProf.cpp.

References OS, and llvm::sampleprof::LineLocation::print().

◆ operator<<() [4/5]

raw_ostream & llvm::sampleprof::operator<< ( raw_ostream OS,
const SampleContext Context 
)
inline

Definition at line 725 of file SampleProf.h.

References OS, and llvm::sampleprof::SampleContext::toString().

◆ operator<<() [5/5]

raw_ostream & llvm::sampleprof::operator<< ( raw_ostream OS,
const SampleRecord Sample 
)

Definition at line 148 of file SampleProf.cpp.

References OS, and llvm::sampleprof::SampleRecord::print().

◆ operator<=()

bool llvm::sampleprof::operator<= ( const FunctionId LHS,
const FunctionId RHS 
)
inline

Definition at line 147 of file FunctionId.h.

References LHS, and RHS.

◆ operator==()

bool llvm::sampleprof::operator== ( const FunctionId LHS,
const FunctionId RHS 
)
inline

Definition at line 135 of file FunctionId.h.

References LHS, llvm::operator==(), and RHS.

◆ operator>()

bool llvm::sampleprof::operator> ( const FunctionId LHS,
const FunctionId RHS 
)
inline

Definition at line 151 of file FunctionId.h.

References LHS, and RHS.

◆ operator>=()

bool llvm::sampleprof::operator>= ( const FunctionId LHS,
const FunctionId RHS 
)
inline

Definition at line 155 of file FunctionId.h.

References LHS, and RHS.

◆ removeSecFlag()

template<class SecFlagType >
static void llvm::sampleprof::removeSecFlag ( SecHdrTableEntry Entry,
SecFlagType  Flag 
)
inlinestatic

Definition at line 256 of file SampleProf.h.

References verifySecFlag().

◆ sortFuncProfiles()

void llvm::sampleprof::sortFuncProfiles ( const SampleProfileMap ProfileMap,
std::vector< NameFunctionSamples > &  SortedProfiles 
)

◆ SPMagic()

static uint64_t llvm::sampleprof::SPMagic ( SampleProfileFormat  Format = SPF_Binary)
inlinestatic

◆ SPVersion()

static uint64_t llvm::sampleprof::SPVersion ( )
inlinestatic

◆ verifySecFlag()

template<class SecFlagType >
static void llvm::sampleprof::verifySecFlag ( SecType  Type,
SecFlagType  Flag 
)
inlinestatic

Variable Documentation

◆ ExtBinaryHdrLayoutTable

const std::array<SmallVector<SecHdrTableEntry, 8>, NumOfLayout> llvm::sampleprof::ExtBinaryHdrLayoutTable
Initial value:
= {
SmallVector<SecHdrTableEntry, 8>({{SecProfSummary, 0, 0, 0, 0},
{SecNameTable, 0, 0, 0, 0},
{SecCSNameTable, 0, 0, 0, 0},
{SecFuncOffsetTable, 0, 0, 0, 0},
{SecLBRProfile, 0, 0, 0, 0},
{SecProfileSymbolList, 0, 0, 0, 0},
{SecFuncMetadata, 0, 0, 0, 0}}),
SmallVector<SecHdrTableEntry, 8>({{SecProfSummary, 0, 0, 0, 0},
{SecNameTable, 0, 0, 0, 0},
{SecFuncOffsetTable, 0, 0, 0, 0},
{SecLBRProfile, 0, 0, 0, 0},
{SecFuncOffsetTable, 0, 0, 0, 0},
{SecLBRProfile, 0, 0, 0, 0},
{SecProfileSymbolList, 0, 0, 0, 0},
{SecFuncMetadata, 0, 0, 0, 0}}),
}

Definition at line 227 of file SampleProfWriter.h.

Referenced by llvm::sampleprof::SampleProfileWriterExtBinaryBase::resetSecLayout().