Thanks to visit codestin.com
Credit goes to llvm.org

LLVM 22.0.0git
llvm::memprof Namespace Reference

Namespaces

namespace  detail
namespace  internal

Classes

struct  AllMemProfData
struct  AllocationInfo
struct  CallerCalleePairExtractor
struct  CallSiteInfo
class  CallStack
 Helper class to iterate through stack ids in both metadata (memprof MIB and callsite) and the corresponding ThinLTO summary data structures (CallsiteInfo and MIBInfo). More...
struct  CallStackIdConverter
class  CallStackLookupTrait
class  CallStackRadixTreeBuilder
class  CallStackTrie
 Class to build a trie of call stack contexts for a particular profiled allocation call, along with their associated allocation types. More...
class  CallStackWriterTrait
class  DataAccessProfData
 Encapsulates the data access profile data and the methods to operate on it. More...
struct  DataAccessProfRecord
 The data access profiles for a symbol. More...
struct  Frame
struct  FrameIdConverter
class  FrameLookupTrait
struct  FrameStat
class  FrameWriterTrait
struct  GUIDMemProfRecordPair
struct  IndexedAllocationInfo
struct  IndexedCallSiteInfo
struct  IndexedCallstackIdConverter
struct  IndexedMemProfData
struct  IndexedMemProfRecord
struct  LinearCallStackIdConverter
struct  LinearFrameIdConverter
struct  LineLocation
struct  LineLocationHash
class  MemProfReader
struct  MemProfRecord
class  MemProfSummary
class  MemProfSummaryBuilder
struct  PortableMemInfoBlock
class  RawMemProfReader
class  RecordLookupTrait
class  RecordWriterTrait
struct  SourceLocation
 The location of data in the source code. Used by profile lookup API. More...
struct  YamlDataAccessProfData
class  YAMLMemProfReader

Typedefs

using SymbolHandleRef = std::variant<StringRef, uint64_t>
using SymbolHandle = std::variant<std::string, uint64_t>
using MemProfSchema = llvm::SmallVector<Meta, static_cast<int>(Meta::Size)>
using FrameId = uint64_t
using LinearFrameId = uint32_t
using CallStackId = uint64_t
using LinearCallStackId = uint32_t
using CallEdgeTy = std::pair<LineLocation, uint64_t>
using CallStackMap = llvm::DenseMap<uint64_t, llvm::SmallVector<uint64_t>>
using LocToLocMap

Enumerations

enum  IndexedVersion : uint64_t { Version2 = 2 , Version3 = 3 , Version4 = 4 }
enum class  Meta : uint64_t { Start = 0 , MIBEntryDef }

Functions

LLVM_ABI bool metadataIncludesAllContextSizeInfo ()
 Whether the alloc memeprof metadata will include context size info for all MIBs.
LLVM_ABI bool metadataMayIncludeContextSizeInfo ()
 Whether the alloc memprof metadata may include context size info for some MIBs (but possibly not all).
LLVM_ABI bool recordContextSizeInfoForAnalysis ()
 Whether we need to record the context size info in the alloc trie used to build metadata.
LLVM_ABI MDNodebuildCallstackMetadata (ArrayRef< uint64_t > CallStack, LLVMContext &Ctx)
 Build callstack metadata from the provided list of call stack ids.
LLVM_ABI MDNodebuildContextSizeMetadata (ArrayRef< ContextTotalSize > ContextSizeInfo, LLVMContext &Ctx)
 Build metadata from the provided list of full stack id and profiled size, to use when reporting of hinted sizes is enabled.
LLVM_ABI MDNodegetMIBStackNode (const MDNode *MIB)
 Returns the stack node from an MIB metadata node.
LLVM_ABI AllocationType getMIBAllocType (const MDNode *MIB)
 Returns the allocation type from an MIB metadata node.
LLVM_ABI std::string getAllocTypeAttributeString (AllocationType Type)
 Returns the string to use in attributes with the given type.
LLVM_ABI bool hasSingleAllocType (uint8_t AllocTypes)
 True if the AllocTypes bitmask contains just a single type.
LLVM_ABI void removeAnyExistingAmbiguousAttribute (CallBase *CB)
 Removes any existing "ambiguous" memprof attribute.
LLVM_ABI void addAmbiguousAttribute (CallBase *CB)
 Adds an "ambiguous" memprof attribute to call with a matched allocation profile but that we haven't yet been able to disambiguate.
llvm::StringRef getMemprofOptionsSymbolDarwinLinkageName ()
llvm::StringRef getMemprofOptionsSymbolName ()
LLVM_ABI MemProfSchema getFullSchema ()
LLVM_ABI MemProfSchema getHotColdSchema ()
LLVM_ABI GlobalValue::GUID getGUID (const StringRef FunctionName)
LLVM_ABI Expected< MemProfSchemareadMemProfSchema (const unsigned char *&Buffer)
LLVM_ABI AllocationType getAllocType (uint64_t TotalLifetimeAccessDensity, uint64_t AllocCount, uint64_t TotalLifetime)
 Return the allocation type for a given set of memory profile values.
LLVM_ABI uint64_t computeFullStackId (ArrayRef< Frame > CallStack)
 Helper to generate a single hash id for a given callstack, used for emitting matching statistics and useful for uniquing such statistics across modules.
template<typename FrameIdTy>
llvm::DenseMap< FrameIdTy, FrameStatcomputeFrameHistogram (llvm::MapVector< CallStackId, llvm::SmallVector< FrameIdTy > > &MemProfCallStackData)
LLVM_ABI DenseMap< uint64_t, SmallVector< CallEdgeTy, 0 > > extractCallsFromIR (Module &M, const TargetLibraryInfo &TLI, function_ref< bool(uint64_t)> IsPresentInProfile=[](uint64_t) { return true;})
LLVM_ABI DenseMap< uint64_t, LocToLocMapcomputeUndriftMap (Module &M, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI)
static std::pair< StringRef, uint64_tsaveStringToMap (DataAccessProfData::StringToIndexMap &Map, llvm::UniqueStringSaver &Saver, StringRef Str)
static Expected< StringRefgetCanonicalName (StringRef Name)
static size_t serializedSizeV2 (const IndexedAllocationInfo &IAI, const MemProfSchema &Schema)
static size_t serializedSizeV3 (const IndexedAllocationInfo &IAI, const MemProfSchema &Schema)
static size_t serializedSizeV2 (const IndexedMemProfRecord &Record, const MemProfSchema &Schema)
static size_t serializedSizeV3 (const IndexedMemProfRecord &Record, const MemProfSchema &Schema)
static size_t serializedSizeV4 (const IndexedMemProfRecord &Record, const MemProfSchema &Schema)
static void serializeV2 (const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS)
static void serializeV3 (const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS, llvm::DenseMap< CallStackId, LinearCallStackId > &MemProfCallStackIndexes)
static void serializeV4 (const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS, llvm::DenseMap< CallStackId, LinearCallStackId > &MemProfCallStackIndexes)
static IndexedMemProfRecord deserializeV2 (const MemProfSchema &Schema, const unsigned char *Ptr)
static IndexedMemProfRecord deserializeV3 (const MemProfSchema &Schema, const unsigned char *Ptr)
static IndexedMemProfRecord deserializeV4 (const MemProfSchema &Schema, const unsigned char *Ptr)
template LLVM_ABI llvm::DenseMap< FrameId, FrameStatcomputeFrameHistogram< FrameId > (llvm::MapVector< CallStackId, llvm::SmallVector< FrameId > > &MemProfCallStackData)
template LLVM_ABI llvm::DenseMap< LinearFrameId, FrameStatcomputeFrameHistogram< LinearFrameId > (llvm::MapVector< CallStackId, llvm::SmallVector< LinearFrameId > > &MemProfCallStackData)

Variables

constexpr uint64_t MinimumSupportedVersion = Version2
constexpr uint64_t MaximumSupportedVersion = Version4
template class LLVM_TEMPLATE_ABI CallStackRadixTreeBuilder< FrameId >
template class LLVM_TEMPLATE_ABI CallStackRadixTreeBuilder< LinearFrameId >

Typedef Documentation

◆ CallEdgeTy

Definition at line 854 of file MemProf.h.

◆ CallStackId

Definition at line 352 of file MemProf.h.

◆ CallStackMap

◆ FrameId

Definition at line 236 of file MemProf.h.

◆ LinearCallStackId

Definition at line 355 of file MemProf.h.

◆ LinearFrameId

Definition at line 238 of file MemProf.h.

◆ LocToLocMap

Initial value:
std::unordered_map<LineLocation, LineLocation, LineLocationHash>

Definition at line 65 of file MemProfUse.h.

◆ MemProfSchema

using llvm::memprof::MemProfSchema = llvm::SmallVector<Meta, static_cast<int>(Meta::Size)>

Definition at line 76 of file MemProf.h.

◆ SymbolHandle

using llvm::memprof::SymbolHandle = std::variant<std::string, uint64_t>

Definition at line 102 of file DataAccessProf.h.

◆ SymbolHandleRef

Definition at line 99 of file DataAccessProf.h.

Enumeration Type Documentation

◆ IndexedVersion

Enumerator
Version2 
Version3 
Version4 

Definition at line 42 of file MemProf.h.

◆ Meta

enum class llvm::memprof::Meta : uint64_t
strong
Enumerator
Start 
MIBEntryDef 

Definition at line 68 of file MemProf.h.

Function Documentation

◆ addAmbiguousAttribute()

void llvm::memprof::addAmbiguousAttribute ( CallBase * CB)

Adds an "ambiguous" memprof attribute to call with a matched allocation profile but that we haven't yet been able to disambiguate.

Definition at line 131 of file MemoryProfileInfo.cpp.

References A(), llvm::CallBase::addFnAttr(), assert(), llvm::Attribute::get(), llvm::Value::getContext(), llvm::CallBase::getFnAttr(), llvm::Attribute::getValueAsString(), and llvm::CallBase::hasFnAttr().

Referenced by llvm::memprof::CallStackTrie::buildAndAttachMIBMetadata().

◆ buildCallstackMetadata()

MDNode * llvm::memprof::buildCallstackMetadata ( ArrayRef< uint64_t > CallStack,
LLVMContext & Ctx )

Build callstack metadata from the provided list of call stack ids.

Returns the resulting metadata node.

Definition at line 68 of file MemoryProfileInfo.cpp.

References llvm::MDNode::get(), llvm::ValueAsMetadata::get(), llvm::Type::getInt64Ty(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), and llvm::SmallVectorImpl< T >::reserve().

Referenced by addCallsiteMetadata(), and createMIBNode().

◆ buildContextSizeMetadata()

LLVM_ABI MDNode * llvm::memprof::buildContextSizeMetadata ( ArrayRef< ContextTotalSize > ContextSizeInfo,
LLVMContext & Ctx )

Build metadata from the provided list of full stack id and profiled size, to use when reporting of hinted sizes is enabled.

References LLVM_ABI.

◆ computeFrameHistogram()

template<typename FrameIdTy>
llvm::DenseMap< FrameIdTy, FrameStat > llvm::memprof::computeFrameHistogram ( llvm::MapVector< CallStackId, llvm::SmallVector< FrameIdTy > > & MemProfCallStackData)

Definition at line 228 of file MemProfRadixTree.cpp.

References E(), and I.

Referenced by llvm::writeMemProfRadixTreeBased().

◆ computeFrameHistogram< FrameId >()

◆ computeFrameHistogram< LinearFrameId >()

◆ computeFullStackId()

uint64_t llvm::memprof::computeFullStackId ( ArrayRef< Frame > CallStack)

Helper to generate a single hash id for a given callstack, used for emitting matching statistics and useful for uniquing such statistics across modules.

Also used to dedup contexts when computing the summary.

Definition at line 73 of file MemProfCommon.cpp.

References llvm::HashBuilder< HasherT, Endianness >::add(), F, llvm::HashBuilderBase< HasherT >::final(), and llvm::little.

Referenced by llvm::memprof::MemProfSummaryBuilder::addRecord(), handleAllocSite(), and CallSiteEntryHash::operator()().

◆ computeUndriftMap()

◆ deserializeV2()

◆ deserializeV3()

◆ deserializeV4()

◆ extractCallsFromIR()

DenseMap< uint64_t, SmallVector< CallEdgeTy, 0 > > llvm::memprof::extractCallsFromIR ( Module & M,
const TargetLibraryInfo & TLI,
function_ref< bool(uint64_t)> IsPresentInProfile = [](uint64_t) { return true; } )

◆ getAllocType()

AllocationType llvm::memprof::getAllocType ( uint64_t TotalLifetimeAccessDensity,
uint64_t AllocCount,
uint64_t TotalLifetime )

Return the allocation type for a given set of memory profile values.

Definition at line 51 of file MemProfCommon.cpp.

References llvm::Cold, llvm::Hot, MemProfAveLifetimeColdThreshold(), MemProfLifetimeAccessDensityColdThreshold(), MemProfMinAveLifetimeAccessDensityHotThreshold(), MemProfUseHotHints(), and llvm::NotCold.

Referenced by addCallStack().

◆ getAllocTypeAttributeString()

std::string llvm::memprof::getAllocTypeAttributeString ( AllocationType Type)

Returns the string to use in attributes with the given type.

Definition at line 101 of file MemoryProfileInfo.cpp.

References assert(), llvm::Cold, llvm::Hot, llvm_unreachable, and llvm::NotCold.

Referenced by llvm::memprof::CallStackTrie::addSingleAllocTypeAttribute(), createMIBNode(), and llvm::MemProfUsePass::run().

◆ getCanonicalName()

◆ getFullSchema()

MemProfSchema llvm::memprof::getFullSchema ( )

◆ getGUID()

◆ getHotColdSchema()

MemProfSchema llvm::memprof::getHotColdSchema ( )

Definition at line 19 of file MemProf.cpp.

Referenced by llvm::writeMemProfRadixTreeBased(), and llvm::writeMemProfV2().

◆ getMemprofOptionsSymbolDarwinLinkageName()

llvm::StringRef llvm::memprof::getMemprofOptionsSymbolDarwinLinkageName ( )
inline

Definition at line 58 of file MemProf.h.

Referenced by getMemprofOptionsSymbolName().

◆ getMemprofOptionsSymbolName()

llvm::StringRef llvm::memprof::getMemprofOptionsSymbolName ( )
inline

◆ getMIBAllocType()

AllocationType llvm::memprof::getMIBAllocType ( const MDNode * MIB)

◆ getMIBStackNode()

MDNode * llvm::memprof::getMIBStackNode ( const MDNode * MIB)

◆ hasSingleAllocType()

bool llvm::memprof::hasSingleAllocType ( uint8_t AllocTypes)

True if the AllocTypes bitmask contains just a single type.

Definition at line 118 of file MemoryProfileInfo.cpp.

References assert(), and llvm::popcount().

Referenced by llvm::memprof::CallStackTrie::buildAndAttachMIBMetadata().

◆ metadataIncludesAllContextSizeInfo()

bool llvm::memprof::metadataIncludesAllContextSizeInfo ( )

Whether the alloc memeprof metadata will include context size info for all MIBs.

Definition at line 55 of file MemoryProfileInfo.cpp.

References MemProfReportHintedSizes, and MinClonedColdBytePercent.

Referenced by computeFunctionSummary(), createMIBNode(), and metadataMayIncludeContextSizeInfo().

◆ metadataMayIncludeContextSizeInfo()

bool llvm::memprof::metadataMayIncludeContextSizeInfo ( )

Whether the alloc memprof metadata may include context size info for some MIBs (but possibly not all).

Definition at line 59 of file MemoryProfileInfo.cpp.

References metadataIncludesAllContextSizeInfo(), and MinPercentMaxColdSize.

Referenced by recordContextSizeInfoForAnalysis().

◆ readMemProfSchema()

Expected< MemProfSchema > llvm::memprof::readMemProfSchema ( const unsigned char *& Buffer)

◆ recordContextSizeInfoForAnalysis()

bool llvm::memprof::recordContextSizeInfoForAnalysis ( )

Whether we need to record the context size info in the alloc trie used to build metadata.

Definition at line 63 of file MemoryProfileInfo.cpp.

References metadataMayIncludeContextSizeInfo(), and MinCallsiteColdBytePercent.

Referenced by addCallStack(), and handleAllocSite().

◆ removeAnyExistingAmbiguousAttribute()

void llvm::memprof::removeAnyExistingAmbiguousAttribute ( CallBase * CB)

Removes any existing "ambiguous" memprof attribute.

Called before we apply a specific allocation type such as "cold", "notcold", or "hot".

Definition at line 124 of file MemoryProfileInfo.cpp.

References assert(), llvm::CallBase::getFnAttr(), llvm::Attribute::getValueAsString(), llvm::CallBase::hasFnAttr(), and llvm::CallBase::removeFnAttr().

Referenced by llvm::memprof::CallStackTrie::addSingleAllocTypeAttribute().

◆ saveStringToMap()

◆ serializedSizeV2() [1/2]

◆ serializedSizeV2() [2/2]

size_t llvm::memprof::serializedSizeV2 ( const IndexedMemProfRecord & Record,
const MemProfSchema & Schema )
static

Definition at line 57 of file MemProf.cpp.

References N, and Version2.

◆ serializedSizeV3() [1/2]

◆ serializedSizeV3() [2/2]

size_t llvm::memprof::serializedSizeV3 ( const IndexedMemProfRecord & Record,
const MemProfSchema & Schema )
static

Definition at line 71 of file MemProf.cpp.

References N, and Version3.

◆ serializedSizeV4()

size_t llvm::memprof::serializedSizeV4 ( const IndexedMemProfRecord & Record,
const MemProfSchema & Schema )
static

Definition at line 86 of file MemProf.cpp.

References N, and Version4.

Referenced by llvm::memprof::IndexedMemProfRecord::serializedSize().

◆ serializeV2()

void llvm::memprof::serializeV2 ( const IndexedMemProfRecord & Record,
const MemProfSchema & Schema,
raw_ostream & OS )
static

Definition at line 114 of file MemProf.cpp.

References llvm::little, and N.

Referenced by llvm::memprof::IndexedMemProfRecord::serialize().

◆ serializeV3()

void llvm::memprof::serializeV3 ( const IndexedMemProfRecord & Record,
const MemProfSchema & Schema,
raw_ostream & OS,
llvm::DenseMap< CallStackId, LinearCallStackId > & MemProfCallStackIndexes )
static

◆ serializeV4()

void llvm::memprof::serializeV4 ( const IndexedMemProfRecord & Record,
const MemProfSchema & Schema,
raw_ostream & OS,
llvm::DenseMap< CallStackId, LinearCallStackId > & MemProfCallStackIndexes )
static

Variable Documentation

◆ CallStackRadixTreeBuilder< FrameId >

◆ CallStackRadixTreeBuilder< LinearFrameId >

◆ MaximumSupportedVersion

◆ MinimumSupportedVersion