LLVM 22.0.0git
llvm::StableFunctionMap Struct Reference

#include "llvm/CGData/StableFunctionMap.h"

Classes

struct  EntryStorage
 In addition to the deserialized StableFunctionEntry, the struct stores the offsets of corresponding serialized stable function entries, and a once flag for safe lazy loading in a multithreaded environment. More...
struct  StableFunctionEntry
 An efficient form of StableFunction for fast look-up. More...

Public Types

enum  SizeType { UniqueHashCount , TotalFunctionCount , MergeableFunctionCount }
using StableFunctionEntries
using HashFuncsMapType = std::unordered_map<stable_hash, EntryStorage>

Public Member Functions

const HashFuncsMapTypegetFunctionMap () const
 Get the HashToFuncs map for serialization.
ArrayRef< std::string > getNames () const
 Get the NameToId vector for serialization.
LLVM_ABI unsigned getIdOrCreateForName (StringRef Name)
 Get an existing ID associated with the given name or create a new ID if it doesn't exist.
LLVM_ABI std::optional< std::string > getNameForId (unsigned Id) const
 Get the name associated with a given ID.
LLVM_ABI void insert (const StableFunction &Func)
 Insert a StableFunction object into the function map.
LLVM_ABI void merge (const StableFunctionMap &OtherMap)
 Merge a OtherMap into this function map.
bool empty () const
bool contains (HashFuncsMapType::key_type FunctionHash) const
const StableFunctionEntriesat (HashFuncsMapType::key_type FunctionHash) const
LLVM_ABI size_t size (SizeType Type=UniqueHashCount) const
LLVM_ABI void finalize (bool SkipTrim=false)
 Finalize the stable function map by trimming content.

Friends

struct StableFunctionMapRecord

Detailed Description

Definition at line 55 of file StableFunctionMap.h.

Member Typedef Documentation

◆ HashFuncsMapType

Definition at line 105 of file StableFunctionMap.h.

◆ StableFunctionEntries

Initial value:
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

Definition at line 78 of file StableFunctionMap.h.

Member Enumeration Documentation

◆ SizeType

Enumerator
UniqueHashCount 
TotalFunctionCount 
MergeableFunctionCount 

Definition at line 144 of file StableFunctionMap.h.

Member Function Documentation

◆ at()

const StableFunctionMap::StableFunctionEntries & StableFunctionMap::at ( HashFuncsMapType::key_type FunctionHash) const
Returns
the stable function entries for the given function hash. If the map is lazily loaded, it will deserialize the entries if it is not already done, other requests to the same hash at the same time will be blocked until the entries are deserialized.

Definition at line 138 of file StableFunctionMap.cpp.

Referenced by llvm::GlobalMergeFunc::merge().

◆ contains()

bool llvm::StableFunctionMap::contains ( HashFuncsMapType::key_type FunctionHash) const
inline
Returns
true if there is an entry for the given function hash. This does not trigger lazy loading.

Definition at line 133 of file StableFunctionMap.h.

Referenced by llvm::GlobalMergeFunc::merge().

◆ empty()

bool llvm::StableFunctionMap::empty ( ) const
inline
Returns
true if there is no stable function entry.

Definition at line 129 of file StableFunctionMap.h.

References size().

◆ finalize()

void StableFunctionMap::finalize ( bool SkipTrim = false)

◆ getFunctionMap()

const StableFunctionMap::HashFuncsMapType & StableFunctionMap::getFunctionMap ( ) const

Get the HashToFuncs map for serialization.

Definition at line 166 of file StableFunctionMap.cpp.

Referenced by getStableFunctionEntries().

◆ getIdOrCreateForName()

unsigned StableFunctionMap::getIdOrCreateForName ( StringRef Name)

Get an existing ID associated with the given name or create a new ID if it doesn't exist.

Definition at line 65 of file StableFunctionMap.cpp.

References assert().

Referenced by insert(), and merge().

◆ getNameForId()

std::optional< std::string > StableFunctionMap::getNameForId ( unsigned Id) const

Get the name associated with a given ID.

Definition at line 76 of file StableFunctionMap.cpp.

Referenced by finalize(), getStableFunctionEntries(), and merge().

◆ getNames()

ArrayRef< std::string > llvm::StableFunctionMap::getNames ( ) const
inline

Get the NameToId vector for serialization.

Definition at line 111 of file StableFunctionMap.h.

◆ insert()

void StableFunctionMap::insert ( const StableFunction & Func)

Insert a StableFunction object into the function map.

This method handles the uniquing of string names and create a StableFunctionEntry for insertion.

Definition at line 82 of file StableFunctionMap.cpp.

References assert(), getIdOrCreateForName(), and insert().

Referenced by insert().

◆ merge()

void StableFunctionMap::merge ( const StableFunctionMap & OtherMap)

Merge a OtherMap into this function map.

Definition at line 95 of file StableFunctionMap.cpp.

References assert(), getIdOrCreateForName(), and getNameForId().

◆ size()

size_t StableFunctionMap::size ( SizeType Type = UniqueHashCount) const
Returns
the size of StableFunctionMap. Type is the type of size to return.

Definition at line 114 of file StableFunctionMap.cpp.

References llvm::Count, llvm_unreachable, MergeableFunctionCount, TotalFunctionCount, and UniqueHashCount.

Referenced by empty().

◆ StableFunctionMapRecord

friend struct StableFunctionMapRecord
friend

Definition at line 190 of file StableFunctionMap.h.

References StableFunctionMapRecord.

Referenced by StableFunctionMapRecord.


The documentation for this struct was generated from the following files: