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

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

#include "llvm/ProfileData/SampleProfReader.h"

Public Types

using OnDiskTableType

Public Member Functions

 SampleProfileFuncOffsetTable (InMemoryModeT, size_t InitialCapacity=0)
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.
void clear ()
 Clear the in-memory map and release the on-disk table.

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.

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

Member Typedef Documentation

◆ OnDiskTableType

Constructor & Destructor Documentation

◆ SampleProfileFuncOffsetTable() [1/2]

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

Definition at line 938 of file SampleProfReader.h.

◆ SampleProfileFuncOffsetTable() [2/2]

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

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

Member Function Documentation

◆ clear()

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

Clear the in-memory map and release the on-disk table.

Definition at line 973 of file SampleProfReader.h.

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

References assert(), and llvm::Offset.

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


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