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

Classes

class  DefaultFunctionPruningStrategy
 
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...
 
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  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< std::string, FunctionSamples, std::less<> >
 
using CallsiteSampleMap = std::map< LineLocation, FunctionSamplesMap >
 
using LocToLocMap = std::unordered_map< LineLocation, LineLocation, LineLocationHash >
 
using SampleProfileMap = std::unordered_map< SampleContext, FunctionSamples, SampleContext::Hash >
 
using NameFunctionSamples = std::pair< SampleContext, 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

static uint64_t SPMagic (SampleProfileFormat Format=SPF_Binary)
 
static StringRef getRepInFormat (StringRef Name, bool UseMD5, std::string &GUIDBuf)
 Get the proper representation of a string according to whether the current Format uses MD5 to represent the string.
 
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 &arg)
 
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 721 of file SampleProf.h.

◆ CallsiteSampleMap

Definition at line 725 of file SampleProf.h.

◆ FunctionSamplesMap

using llvm::sampleprof::FunctionSamplesMap = typedef std::map<std::string, FunctionSamples, std::less<> >

Definition at line 724 of file SampleProf.h.

◆ InlineCallStack

Definition at line 824 of file SampleProfReader.h.

◆ LocToLocMap

Definition at line 726 of file SampleProf.h.

◆ NameFunctionSamples

Definition at line 1273 of file SampleProf.h.

◆ SampleContextFrames

Definition at line 505 of file SampleProf.h.

◆ SampleContextFrameVector

Definition at line 504 of file SampleProf.h.

◆ SampleProfileMap

Definition at line 1270 of file SampleProf.h.

Enumeration Type Documentation

◆ ContextAttributeMask

Enumerator
ContextNone 
ContextWasInlined 
ContextShouldBeInlined 
ContextDuplicatedIntoBase 

Definition at line 461 of file SampleProf.h.

◆ ContextStateMask

Enumerator
UnknownContext 
RawContext 
SyntheticContext 
InlinedContext 
MergedContext 

Definition at line 452 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 828 of file SampleProfReader.h.

◆ SampleProfileFormat

Enumerator
SPF_None 
SPF_Text 
SPF_Compact_Binary 
SPF_GCC 
SPF_Ext_Binary 
SPF_Binary 

Definition at line 90 of file SampleProf.h.

◆ SampleProfileLayout

Enumerator
SPL_None 
SPL_Nest 
SPL_Flat 

Definition at line 99 of file SampleProf.h.

◆ SecCommonFlags

Enumerator
SecFlagInValid 
SecFlagCompress 
SecFlagFlat 

Definition at line 178 of file SampleProf.h.

◆ SecFuncMetadataFlags

Enumerator
SecFlagInvalid 
SecFlagIsProbeBased 
SecFlagHasAttribute 

Definition at line 215 of file SampleProf.h.

◆ SecFuncOffsetFlags

Enumerator
SecFlagInvalid 
SecFlagOrdered 

Definition at line 221 of file SampleProf.h.

◆ SecNameTableFlags

Enumerator
SecFlagInValid 
SecFlagMD5Name 
SecFlagFixedLengthMD5 
SecFlagUniqSuffix 

Definition at line 188 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 198 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 127 of file SampleProf.h.

Function Documentation

◆ addSecFlag()

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

◆ getRepInFormat()

static StringRef llvm::sampleprof::getRepInFormat ( StringRef  Name,
bool  UseMD5,
std::string &  GUIDBuf 
)
inlinestatic

◆ getSecName()

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

◆ hash_value() [1/2]

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

◆ hash_value() [2/2]

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

◆ hasSecFlag()

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

◆ operator<<() [1/3]

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

Definition at line 195 of file SampleProf.cpp.

References OS.

◆ operator<<() [2/3]

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<<() [3/3]

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().

◆ removeSecFlag()

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

Definition at line 265 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().