LLVM 24.0.0git
llvm::sampleprof::SampleProfileFuncOffsetTable Class Reference

A unified wrapper representing the function offset table. More...

#include "llvm/ProfileData/SampleProfReader.h"

Public Types

enum class  TableMode { InMemory , OnDisk , Eytzinger }
using OnDiskTableType

Public Member Functions

 SampleProfileFuncOffsetTable ()=delete
 SampleProfileFuncOffsetTable (const SampleProfileFuncOffsetTable &)=delete
SampleProfileFuncOffsetTableoperator= (const SampleProfileFuncOffsetTable &)=delete
 SampleProfileFuncOffsetTable (SampleProfileFuncOffsetTable &&)=delete
SampleProfileFuncOffsetTableoperator= (SampleProfileFuncOffsetTable &&)=delete
 SampleProfileFuncOffsetTable (InMemoryModeT, size_t InitialCapacity=0)
 SampleProfileFuncOffsetTable (EytzingerModeT, EytzingerTableSpan< support::ulittle64_t > NameSpan, ArrayRef< support::ulittle32_t > FuncOffsetSpan)
void insert (uint64_t GUID, uint64_t Offset)
 Insert a function GUID and its profile offset into the in-memory map.
 SampleProfileFuncOffsetTable (OnDiskModeT, const uint8_t *Buckets, const uint8_t *Payload, const uint8_t *Base)
 Instantiate the on-disk chained hash table using raw stream pointers.
std::optional< uint64_tlookup (uint64_t GUID) const
 Query the offset table for the profile offset associated with the given GUID.
ArrayRef< support::ulittle32_tgetFuncOffsets () const
 Direct read-only array (ArrayRef) of function offsets aligned parallel to the corresponding Eytzinger name span.
size_t getExpectedSize () const
bool isEytzinger () const

Detailed Description

A unified wrapper representing the function offset table.

This class abstracts away the physical representation of the offset table, which can either be:

  • An llvm::DenseMap mapping function GUIDs (or context hashes) to their profile offsets, populated when reading the array of offsets in context-sensitive (CS) profiles or version 103 profiles.
  • An OnDiskIterableChainedHashTable providing the same mapping directly from the file in (non-context-sensitive) version 104 profiles.
  • A raw slice of 32-bit relative offsets for Eytzinger parallel lookups.

It exposes a single, type-agnostic lookup interface, shielding the reader from the underlying container types. To prevent hybrid-state corruption, the table's mode is locked at construction time, and assertions prevent modification in on-disk mode.

Definition at line 1043 of file SampleProfReader.h.

Member Typedef Documentation

◆ OnDiskTableType

Member Enumeration Documentation

◆ TableMode

Enumerator
InMemory 
OnDisk 
Eytzinger 

Definition at line 1045 of file SampleProfReader.h.

Constructor & Destructor Documentation

◆ SampleProfileFuncOffsetTable() [1/6]

llvm::sampleprof::SampleProfileFuncOffsetTable::SampleProfileFuncOffsetTable ( )
delete

◆ SampleProfileFuncOffsetTable() [2/6]

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

◆ SampleProfileFuncOffsetTable() [3/6]

llvm::sampleprof::SampleProfileFuncOffsetTable::SampleProfileFuncOffsetTable ( SampleProfileFuncOffsetTable && )
delete

◆ SampleProfileFuncOffsetTable() [4/6]

llvm::sampleprof::SampleProfileFuncOffsetTable::SampleProfileFuncOffsetTable ( InMemoryModeT ,
size_t InitialCapacity = 0 )
inlineexplicit

Definition at line 1058 of file SampleProfReader.h.

References InMemory.

◆ SampleProfileFuncOffsetTable() [5/6]

llvm::sampleprof::SampleProfileFuncOffsetTable::SampleProfileFuncOffsetTable ( EytzingerModeT ,
EytzingerTableSpan< support::ulittle64_t > NameSpan,
ArrayRef< support::ulittle32_t > FuncOffsetSpan )
inline

Definition at line 1064 of file SampleProfReader.h.

References Eytzinger.

◆ SampleProfileFuncOffsetTable() [6/6]

llvm::sampleprof::SampleProfileFuncOffsetTable::SampleProfileFuncOffsetTable ( OnDiskModeT ,
const uint8_t * Buckets,
const uint8_t * Payload,
const uint8_t * Base )
inline

Instantiate the on-disk chained hash table using raw stream pointers.

Definition at line 1079 of file SampleProfReader.h.

References llvm::sampleprof::Base, llvm::OnDiskIterableChainedHashTable< FuncOffsetHashTableInfo >::Create(), and OnDisk.

Member Function Documentation

◆ getExpectedSize()

size_t llvm::sampleprof::SampleProfileFuncOffsetTable::getExpectedSize ( ) const
inline

Definition at line 1116 of file SampleProfReader.h.

References assert(), and isEytzinger().

◆ getFuncOffsets()

ArrayRef< support::ulittle32_t > llvm::sampleprof::SampleProfileFuncOffsetTable::getFuncOffsets ( ) const
inline

Direct read-only array (ArrayRef) of function offsets aligned parallel to the corresponding Eytzinger name span.

Definition at line 1110 of file SampleProfReader.h.

References assert(), and isEytzinger().

◆ insert()

void llvm::sampleprof::SampleProfileFuncOffsetTable::insert ( uint64_t GUID,
uint64_t Offset )
inline

Insert a function GUID and its profile offset into the in-memory map.

Enforces that the on-disk table must not have been set first.

Definition at line 1072 of file SampleProfReader.h.

References assert(), and llvm::Offset.

◆ isEytzinger()

bool llvm::sampleprof::SampleProfileFuncOffsetTable::isEytzinger ( ) const
inline

Definition at line 1122 of file SampleProfReader.h.

References Eytzinger.

Referenced by getExpectedSize(), getFuncOffsets(), and lookup().

◆ lookup()

std::optional< uint64_t > llvm::sampleprof::SampleProfileFuncOffsetTable::lookup ( uint64_t GUID) const
inline

Query the offset table for the profile offset associated with the given GUID.

Returns the offset if found, or std::nullopt if the key is missing.

Definition at line 1087 of file SampleProfReader.h.

References isEytzinger().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

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