LLVM 23.0.0git
llvm::sampleprof::SampleProfileNameTable Class Reference

Sample-based profile reader. More...

#include "llvm/ProfileData/SampleProfReader.h"

Classes

class  iterator
 iterator is a lightweight, self-contained input iterator designed to stream FunctionId symbols from either the memory-mapped file buffer (lazy loading from the FixedMD5 layout) or from an eagerly loaded vector of FunctionId objects (fallback). More...

Public Types

using const_iterator = iterator

Public Member Functions

 SampleProfileNameTable ()=default
void clear ()
void setLazy (const uint8_t *S, size_t Sz)
 Transitions the table to lazy-loading mode, pointing directly to a contiguous buffer of little-endian 64-bit MD5 hashes.
std::vector< FunctionId > & setToEager ()
 Transitions the table to eager-loading mode by clearing previous state and returning a mutable reference to the underlying vector for population.
size_t size () const
bool empty () const
FunctionId operator[] (size_t Idx) const
iterator begin () const
iterator end () const

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 352 of file SampleProfReader.h.

Member Typedef Documentation

◆ const_iterator

Constructor & Destructor Documentation

◆ SampleProfileNameTable()

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

Member Function Documentation

◆ begin()

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

◆ clear()

void llvm::sampleprof::SampleProfileNameTable::clear ( )
inline

Definition at line 407 of file SampleProfReader.h.

Referenced by setLazy(), and setToEager().

◆ empty()

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

Definition at line 429 of file SampleProfReader.h.

References size().

◆ end()

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

◆ operator[]()

FunctionId llvm::sampleprof::SampleProfileNameTable::operator[] ( size_t Idx) const
inline

Definition at line 431 of file SampleProfReader.h.

References assert(), and size().

◆ setLazy()

void llvm::sampleprof::SampleProfileNameTable::setLazy ( const uint8_t * S,
size_t Sz )
inline

Transitions the table to lazy-loading mode, pointing directly to a contiguous buffer of little-endian 64-bit MD5 hashes.

Definition at line 415 of file SampleProfReader.h.

References clear().

◆ setToEager()

std::vector< FunctionId > & llvm::sampleprof::SampleProfileNameTable::setToEager ( )
inline

Transitions the table to eager-loading mode by clearing previous state and returning a mutable reference to the underlying vector for population.

Definition at line 423 of file SampleProfReader.h.

References clear().

◆ size()

size_t llvm::sampleprof::SampleProfileNameTable::size ( ) const
inline

Definition at line 428 of file SampleProfReader.h.

Referenced by empty(), and operator[]().


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