LLVM 24.0.0git
llvm::sampleprof::SampleProfileNameTable Class Referenceabstract

Sample-based profile reader. More...

#include "llvm/ProfileData/SampleProfReader.h"

Inheritance diagram for llvm::sampleprof::SampleProfileNameTable:
[legend]

Classes

class  iterator

Public Types

using const_iterator = iterator

Public Member Functions

 SampleProfileNameTable ()=default
 SampleProfileNameTable (const SampleProfileNameTable &)=delete
 SampleProfileNameTable (SampleProfileNameTable &&)=delete
SampleProfileNameTableoperator= (const SampleProfileNameTable &)=delete
SampleProfileNameTableoperator= (SampleProfileNameTable &&)=delete
virtual ~SampleProfileNameTable ()=default
virtual size_t size () const =0
bool empty () const
virtual FunctionId operator[] (size_t Idx) const =0
virtual bool contains (StringRef Key) const
virtual bool contains (uint64_t GUID) const
iterator begin () const
iterator end () const

Static Protected Member Functions

template<typename SetT, typename RangeT, typename ProjT = llvm::identity>
static const SetT & getOrCreateSet (std::optional< SetT > &Set, const RangeT &Range, ProjT Proj=ProjT())

Protected Attributes

std::optional< DenseSet< uint64_t > > GUIDSet

Static Protected Attributes

static constexpr auto GetFunctionIdHash
static constexpr auto GetFunctionIdString

Detailed Description

Sample-based profile reader.

Each profile contains sample counts for all the functions executed. Inside each function, statements are annotated with the collected samples on all the instructions associated with that statement.

For this to produce meaningful data, the program needs to be compiled with some debug information (at minimum, line numbers: -gline-tables-only). Otherwise, it will be impossible to match IR instructions to the line numbers collected by the profiler.

From the profile file, we are interested in collecting the following information:

  • A list of functions included in the profile (mangled names).
  • For each function F:
    1. The total number of samples collected in F.
    2. The samples collected at each line in F. To provide some protection against source code shuffling, line numbers should be relative to the start of the function.

The reader supports two file formats: text and binary. The text format is useful for debugging and testing, while the binary format is more compact and I/O efficient. They can both be used interchangeably. Manages the sample profile name table, supporting both an eagerly loaded std::vector of FunctionId objects and lazy-loaded MD5 hashes read directly from the memory-mapped buffer. It enforces the exclusivity of these two formats and provides a unified read-only container interface.

Definition at line 357 of file SampleProfReader.h.

Member Typedef Documentation

◆ const_iterator

Constructor & Destructor Documentation

◆ SampleProfileNameTable() [1/3]

llvm::sampleprof::SampleProfileNameTable::SampleProfileNameTable ( )
default

◆ SampleProfileNameTable() [2/3]

llvm::sampleprof::SampleProfileNameTable::SampleProfileNameTable ( const SampleProfileNameTable & )
delete

◆ SampleProfileNameTable() [3/3]

llvm::sampleprof::SampleProfileNameTable::SampleProfileNameTable ( SampleProfileNameTable && )
delete

◆ ~SampleProfileNameTable()

virtual llvm::sampleprof::SampleProfileNameTable::~SampleProfileNameTable ( )
virtualdefault

Member Function Documentation

◆ begin()

iterator llvm::sampleprof::SampleProfileNameTable::begin ( ) const
inline

Definition at line 407 of file SampleProfReader.h.

◆ contains() [1/2]

virtual bool llvm::sampleprof::SampleProfileNameTable::contains ( StringRef Key) const
inlinevirtual

◆ contains() [2/2]

virtual bool llvm::sampleprof::SampleProfileNameTable::contains ( uint64_t GUID) const
inlinevirtual

◆ empty()

bool llvm::sampleprof::SampleProfileNameTable::empty ( ) const
inline

Definition at line 398 of file SampleProfReader.h.

References size().

◆ end()

iterator llvm::sampleprof::SampleProfileNameTable::end ( ) const
inline

Definition at line 408 of file SampleProfReader.h.

References size().

◆ getOrCreateSet()

template<typename SetT, typename RangeT, typename ProjT = llvm::identity>
const SetT & llvm::sampleprof::SampleProfileNameTable::getOrCreateSet ( std::optional< SetT > & Set,
const RangeT & Range,
ProjT Proj = ProjT() )
inlinestaticprotected

◆ operator=() [1/2]

SampleProfileNameTable & llvm::sampleprof::SampleProfileNameTable::operator= ( const SampleProfileNameTable & )
delete

◆ operator=() [2/2]

SampleProfileNameTable & llvm::sampleprof::SampleProfileNameTable::operator= ( SampleProfileNameTable && )
delete

◆ operator[]()

◆ size()

Member Data Documentation

◆ GetFunctionIdHash

auto llvm::sampleprof::SampleProfileNameTable::GetFunctionIdHash
staticconstexprprotected
Initial value:
= [](FunctionId F) {
return F.getHashCode();
}
#define F(x, y, z)
Definition MD5.cpp:54
This class represents a function that is read from a sample profile.
Definition FunctionId.h:36

Definition at line 413 of file SampleProfReader.h.

Referenced by contains().

◆ GetFunctionIdString

auto llvm::sampleprof::SampleProfileNameTable::GetFunctionIdString
staticconstexprprotected
Initial value:
= [](FunctionId F) {
return F.stringRef();
}

Definition at line 416 of file SampleProfReader.h.

Referenced by llvm::sampleprof::StringSampleProfileNameTable::contains().

◆ GUIDSet

std::optional<DenseSet<uint64_t> > llvm::sampleprof::SampleProfileNameTable::GUIDSet
mutableprotected

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