LLVM 20.0.0git
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
llvm::memprof Namespace Reference

Namespaces

namespace  detail
 

Classes

struct  AllMemProfData
 
struct  AllocationInfo
 
struct  CallerCalleePairExtractor
 
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
 
struct  Frame
 
struct  FrameIdConverter
 
class  FrameLookupTrait
 
struct  FrameStat
 
class  FrameWriterTrait
 
struct  GUIDMemProfRecordPair
 
struct  IndexedAllocationInfo
 
struct  IndexedCallstackIdConveter
 
struct  IndexedMemProfData
 
struct  IndexedMemProfRecord
 
struct  LinearCallStackIdConverter
 
struct  LinearFrameIdConverter
 
struct  LineLocation
 
struct  LineLocationHash
 
class  MemProfReader
 
struct  MemProfRecord
 
struct  PortableMemInfoBlock
 
class  RawMemProfReader
 
class  RecordLookupTrait
 
class  RecordWriterTrait
 
class  YAMLMemProfReader
 

Typedefs

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 }
 
enum class  Meta : uint64_t { Start = 0 , MIBEntryDef , Size }
 

Functions

AllocationType getAllocType (uint64_t TotalLifetimeAccessDensity, uint64_t AllocCount, uint64_t TotalLifetime)
 Return the allocation type for a given set of memory profile values.
 
MDNodebuildCallstackMetadata (ArrayRef< uint64_t > CallStack, LLVMContext &Ctx)
 Build callstack metadata from the provided list of call stack ids.
 
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.
 
MDNodegetMIBStackNode (const MDNode *MIB)
 Returns the stack node from an MIB metadata node.
 
AllocationType getMIBAllocType (const MDNode *MIB)
 Returns the allocation type from an MIB metadata node.
 
std::string getAllocTypeAttributeString (AllocationType Type)
 Returns the string to use in attributes with the given type.
 
bool hasSingleAllocType (uint8_t AllocTypes)
 True if the AllocTypes bitmask contains just a single type.
 
MemProfSchema getFullSchema ()
 
MemProfSchema getHotColdSchema ()
 
Expected< MemProfSchemareadMemProfSchema (const unsigned char *&Buffer)
 
template<typename FrameIdTy >
llvm::DenseMap< FrameIdTy, FrameStatcomputeFrameHistogram (llvm::MapVector< CallStackId, llvm::SmallVector< FrameIdTy > > &MemProfCallStackData)
 
DenseMap< uint64_t, SmallVector< CallEdgeTy, 0 > > extractCallsFromIR (Module &M, const TargetLibraryInfo &TLI)
 
DenseMap< uint64_t, LocToLocMapcomputeUndriftMap (Module &M, IndexedInstrProfReader *MemProfReader, const TargetLibraryInfo &TLI)
 
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 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 IndexedMemProfRecord deserializeV2 (const MemProfSchema &Schema, const unsigned char *Ptr)
 
static IndexedMemProfRecord deserializeV3 (const MemProfSchema &Schema, const unsigned char *Ptr)
 
template llvm::DenseMap< FrameId, FrameStatcomputeFrameHistogram< FrameId > (llvm::MapVector< CallStackId, llvm::SmallVector< FrameId > > &MemProfCallStackData)
 
template llvm::DenseMap< LinearFrameId, FrameStatcomputeFrameHistogram< LinearFrameId > (llvm::MapVector< CallStackId, llvm::SmallVector< LinearFrameId > > &MemProfCallStackData)
 

Variables

constexpr uint64_t MinimumSupportedVersion = Version2
 
constexpr uint64_t MaximumSupportedVersion = Version3
 

Typedef Documentation

◆ CallEdgeTy

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

Definition at line 913 of file MemProf.h.

◆ CallStackId

Definition at line 329 of file MemProf.h.

◆ CallStackMap

Definition at line 104 of file MemProfReader.h.

◆ FrameId

Definition at line 213 of file MemProf.h.

◆ LinearCallStackId

Definition at line 332 of file MemProf.h.

◆ LinearFrameId

Definition at line 215 of file MemProf.h.

◆ LocToLocMap

Definition at line 78 of file MemProfiler.h.

◆ MemProfSchema

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

Definition at line 53 of file MemProf.h.

Enumeration Type Documentation

◆ IndexedVersion

Enumerator
Version2 
Version3 

Definition at line 31 of file MemProf.h.

◆ Meta

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

Definition at line 45 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 70 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()

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 515 of file MemProf.cpp.

References E, and I.

Referenced by writeMemProfV3().

◆ computeFrameHistogram< FrameId >()

◆ computeFrameHistogram< LinearFrameId >()

◆ 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

◆ extractCallsFromIR()

DenseMap< uint64_t, SmallVector< CallEdgeTy, 0 > > llvm::memprof::extractCallsFromIR ( Module M,
const TargetLibraryInfo TLI 
)

◆ 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 49 of file MemoryProfileInfo.cpp.

References MemProfAveLifetimeColdThreshold, MemProfLifetimeAccessDensityColdThreshold, and MemProfMinAveLifetimeAccessDensityHotThreshold.

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 103 of file MemoryProfileInfo.cpp.

References assert(), and llvm_unreachable.

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

◆ getFullSchema()

MemProfSchema llvm::memprof::getFullSchema ( )

◆ getHotColdSchema()

MemProfSchema llvm::memprof::getHotColdSchema ( )

Definition at line 21 of file MemProf.cpp.

Referenced by writeMemProfV2(), and writeMemProfV3().

◆ getMIBAllocType()

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

Returns the allocation type from an MIB metadata node.

Definition at line 88 of file MemoryProfileInfo.cpp.

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

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

◆ getMIBStackNode()

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

Returns the stack node from an MIB metadata node.

Definition at line 82 of file MemoryProfileInfo.cpp.

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

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

◆ hasSingleAllocType()

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

True if the AllocTypes bitmask contains just a single type.

Definition at line 127 of file MemoryProfileInfo.cpp.

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

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

◆ readMemProfSchema()

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

Definition at line 267 of file MemProf.cpp.

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

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

◆ serializeV2()

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

Definition at line 96 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

Variable Documentation

◆ MaximumSupportedVersion

constexpr uint64_t llvm::memprof::MaximumSupportedVersion = Version3
constexpr

◆ MinimumSupportedVersion

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