LLVM 22.0.0git
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
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 = std::unordered_map< LineLocation, LineLocation, LineLocationHash >
 

Enumerations

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

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::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

using llvm::memprof::CallEdgeTy = typedef std::pair<LineLocation, uint64_t>

Definition at line 854 of file MemProf.h.

◆ CallStackId

Definition at line 352 of file MemProf.h.

◆ CallStackMap

Definition at line 105 of file MemProfReader.h.

◆ 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

Definition at line 65 of file MemProfUse.h.

◆ MemProfSchema

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

Definition at line 76 of file MemProf.h.

◆ SymbolHandle

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

Definition at line 102 of file DataAccessProf.h.

◆ SymbolHandleRef

using llvm::memprof::SymbolHandleRef = typedef std::variant<StringRef, uint64_t>

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 
Size 

Definition at line 68 of file MemProf.h.

Function Documentation

◆ 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.

◆ 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()

DenseMap< uint64_t, LocToLocMap > llvm::memprof::computeUndriftMap ( Module M,
IndexedInstrProfReader MemProfReader,
const TargetLibraryInfo TLI 
)

◆ deserializeV2()

static IndexedMemProfRecord llvm::memprof::deserializeV2 ( const MemProfSchema Schema,
const unsigned char Ptr 
)
static

◆ deserializeV3()

static IndexedMemProfRecord llvm::memprof::deserializeV3 ( const MemProfSchema Schema,
const unsigned char Ptr 
)
static

◆ deserializeV4()

static IndexedMemProfRecord llvm::memprof::deserializeV4 ( const MemProfSchema Schema,
const unsigned char Ptr 
)
static

◆ 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 MemProfAveLifetimeColdThreshold(), MemProfLifetimeAccessDensityColdThreshold(), MemProfMinAveLifetimeAccessDensityHotThreshold(), and MemProfUseHotHints().

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(), and llvm_unreachable.

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

◆ getCanonicalName()

static Expected< StringRef > llvm::memprof::getCanonicalName ( StringRef  Name)
static

◆ getFullSchema()

MemProfSchema llvm::memprof::getFullSchema ( )

◆ getGUID()

GlobalValue::GUID llvm::memprof::getGUID ( const StringRef  FunctionName)

◆ 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)

Returns the allocation type from an MIB metadata node.

Definition at line 86 of file MemoryProfileInfo.cpp.

References assert(), llvm::MDNode::getNumOperands(), and llvm::MDNode::getOperand().

Referenced by llvm::memprof::CallStackTrie::addCallStack(), computeFunctionSummary(), and saveFilteredNewMIBNodes().

◆ 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)

Definition at line 360 of file MemProf.cpp.

References I, llvm::malformed, Ptr, Size, and llvm::Tag.

◆ 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().

◆ saveStringToMap()

static std::pair< StringRef, uint64_t > llvm::memprof::saveStringToMap ( DataAccessProfData::StringToIndexMap Map,
llvm::UniqueStringSaver Saver,
StringRef  Str 
)
static

◆ serializedSizeV2() [1/2]

static size_t llvm::memprof::serializedSizeV2 ( const IndexedAllocationInfo IAI,
const MemProfSchema Schema 
)
static

◆ serializedSizeV2() [2/2]

static 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]

static size_t llvm::memprof::serializedSizeV3 ( const IndexedAllocationInfo IAI,
const MemProfSchema Schema 
)
static

◆ serializedSizeV3() [2/2]

static 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()

static 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()

static 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, N, and OS.

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

◆ serializeV3()

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

◆ serializeV4()

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

Variable Documentation

◆ CallStackRadixTreeBuilder< FrameId >

Definition at line 223 of file MemProfRadixTree.cpp.

◆ CallStackRadixTreeBuilder< LinearFrameId >

Definition at line 224 of file MemProfRadixTree.cpp.

◆ MaximumSupportedVersion

constexpr uint64_t llvm::memprof::MaximumSupportedVersion = Version4
constexpr

◆ MinimumSupportedVersion

constexpr uint64_t llvm::memprof::MinimumSupportedVersion = Version2
constexpr