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

Classes

class  FunctionSamples
 Representation of the samples collected for a function. More...
 
struct  LineLocation
 Represents the relative location of an instruction. More...
 
class  ProfiledCallGraph
 
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  SampleProfileReaderCompactBinary
 
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  SampleProfileWriterCompactBinary
 
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, 10 >
 
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 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  SecType {
  SecInValid = 0, SecProfSummary = 1, SecNameTable = 2, SecProfileSymbolList = 3,
  SecFuncOffsetTable = 4, SecFuncMetadata = 5, SecCSNameTable = 6, SecFuncProfileFirst = 32,
  SecLBRProfile = SecFuncProfileFirst
}
 
enum  SecCommonFlags : uint32_t { SecCommonFlags::SecFlagInValid = 0, SecCommonFlags::SecFlagCompress = (1 << 0), SecCommonFlags::SecFlagFlat = (1 << 1) }
 
enum  SecNameTableFlags : uint32_t { SecNameTableFlags::SecFlagInValid = 0, SecNameTableFlags::SecFlagMD5Name = (1 << 0), SecNameTableFlags::SecFlagFixedLengthMD5 = (1 << 1), SecNameTableFlags::SecFlagUniqSuffix = (1 << 2) }
 
enum  SecProfSummaryFlags : uint32_t { SecProfSummaryFlags::SecFlagInValid = 0, SecProfSummaryFlags::SecFlagPartial = (1 << 0), SecProfSummaryFlags::SecFlagFullContext = (1 << 1), SecProfSummaryFlags::SecFlagFSDiscriminator = (1 << 2) }
 
enum  SecFuncMetadataFlags : uint32_t { SecFuncMetadataFlags::SecFlagInvalid = 0, SecFuncMetadataFlags::SecFlagIsProbeBased = (1 << 0), SecFuncMetadataFlags::SecFlagHasAttribute = (1 << 1) }
 
enum  SecFuncOffsetFlags : uint32_t { SecFuncOffsetFlags::SecFlagInvalid = 0, SecFuncOffsetFlags::SecFlagOrdered = (1 << 0) }
 
enum  ContextStateMask {
  UnknownContext = 0x0, RawContext = 0x1, SyntheticContext = 0x2, InlinedContext = 0x4,
  MergedContext = 0x8
}
 
enum  ContextAttributeMask { ContextNone = 0x0, ContextWasInlined = 0x1, ContextShouldBeInlined = 0x2 }
 
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. More...
 
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 673 of file SampleProf.h.

◆ CallsiteSampleMap

Definition at line 677 of file SampleProf.h.

◆ FunctionSamplesMap

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

Definition at line 676 of file SampleProf.h.

◆ InlineCallStack

Definition at line 838 of file SampleProfReader.h.

◆ NameFunctionSamples

Definition at line 1093 of file SampleProf.h.

◆ SampleContextFrames

Definition at line 451 of file SampleProf.h.

◆ SampleContextFrameVector

Definition at line 450 of file SampleProf.h.

◆ SampleProfileMap

Definition at line 1091 of file SampleProf.h.

Enumeration Type Documentation

◆ ContextAttributeMask

Enumerator
ContextNone 
ContextWasInlined 
ContextShouldBeInlined 

Definition at line 409 of file SampleProf.h.

◆ ContextStateMask

Enumerator
UnknownContext 
RawContext 
SyntheticContext 
InlinedContext 
MergedContext 

Definition at line 400 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 842 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.

◆ SecCommonFlags

Enumerator
SecFlagInValid 
SecFlagCompress 
SecFlagFlat 

Definition at line 172 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 182 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 profile for CSSPGO.

SecFlagFSDiscriminator 

SecFlagFSDiscriminator means this profile uses flow-sensitive discriminators.

Definition at line 192 of file SampleProf.h.

◆ SectionLayout

Enumerator
DefaultLayout 
CtxSplitLayout 
NumOfLayout 

Definition at line 33 of file SampleProfWriter.h.

◆ SecType

Enumerator
SecInValid 
SecProfSummary 
SecNameTable 
SecProfileSymbolList 
SecFuncOffsetTable 
SecFuncMetadata 
SecCSNameTable 
SecFuncProfileFirst 
SecLBRProfile 

Definition at line 121 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

Definition at line 264 of file SampleProf.h.

◆ operator<<() [1/3]

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

Definition at line 195 of file SampleProf.cpp.

References llvm::X86AS::FS.

◆ operator<<() [2/3]

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

Definition at line 111 of file SampleProf.cpp.

References 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 llvm::sampleprof::SampleRecord::print().

◆ removeSecFlag()

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

Definition at line 256 of file SampleProf.h.

◆ 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 161 of file SampleProfWriter.h.

llvm::sampleprof::SecFuncOffsetTable
@ SecFuncOffsetTable
Definition: SampleProf.h:126
llvm::sampleprof::SecProfSummary
@ SecProfSummary
Definition: SampleProf.h:123
llvm::sampleprof::SecLBRProfile
@ SecLBRProfile
Definition: SampleProf.h:131
llvm::sampleprof::SecProfileSymbolList
@ SecProfileSymbolList
Definition: SampleProf.h:125
llvm::sampleprof::SecCSNameTable
@ SecCSNameTable
Definition: SampleProf.h:128
llvm::sampleprof::SecNameTable
@ SecNameTable
Definition: SampleProf.h:124
llvm::sampleprof::SecFuncMetadata
@ SecFuncMetadata
Definition: SampleProf.h:127