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

Namespaces

namespace  detail
 

Classes

struct  AllocationInfo
 
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  IndexedAllocationInfo
 
struct  IndexedMemProfData
 
struct  IndexedMemProfRecord
 
struct  LinearCallStackIdConverter
 
struct  LinearFrameIdConverter
 
class  MemProfReader
 
struct  MemProfRecord
 
struct  PortableMemInfoBlock
 
class  RawMemProfReader
 
class  RecordLookupTrait
 
class  RecordWriterTrait
 

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 CallStackMap = llvm::DenseMap< uint64_t, llvm::SmallVector< uint64_t > >
 

Enumerations

enum  IndexedVersion : uint64_t { Version0 = 0 , Version1 = 1 , 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.
 
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.
 
uint64_t getMIBTotalSize (const MDNode *MIB)
 Returns the total size from an MIB metadata node, or 0 if it was not recorded.
 
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)
 
CallStackId hashCallStack (ArrayRef< FrameId > CS)
 
llvm::DenseMap< FrameId, FrameStatcomputeFrameHistogram (llvm::MapVector< CallStackId, llvm::SmallVector< FrameId > > &MemProfCallStackData)
 
void verifyIndexedMemProfRecord (const IndexedMemProfRecord &Record)
 
void verifyFunctionProfileData (const llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > &FunctionProfileData)
 
static size_t serializedSizeV0 (const IndexedAllocationInfo &IAI, const MemProfSchema &Schema)
 
static size_t serializedSizeV2 (const IndexedAllocationInfo &IAI, const MemProfSchema &Schema)
 
static size_t serializedSizeV3 (const IndexedAllocationInfo &IAI, const MemProfSchema &Schema)
 
static size_t serializedSizeV0 (const IndexedMemProfRecord &Record, 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 serializeV0 (const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS)
 
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 deserializeV0 (const MemProfSchema &Schema, const unsigned char *Ptr)
 
static IndexedMemProfRecord deserializeV2 (const MemProfSchema &Schema, const unsigned char *Ptr)
 
static IndexedMemProfRecord deserializeV3 (const MemProfSchema &Schema, const unsigned char *Ptr)
 

Variables

constexpr uint64_t MinimumSupportedVersion = Version0
 
constexpr uint64_t MaximumSupportedVersion = Version3
 

Typedef Documentation

◆ CallStackId

Definition at line 333 of file MemProf.h.

◆ CallStackMap

Definition at line 132 of file MemProfReader.h.

◆ FrameId

Definition at line 198 of file MemProf.h.

◆ LinearCallStackId

Definition at line 336 of file MemProf.h.

◆ LinearFrameId

Definition at line 200 of file MemProf.h.

◆ MemProfSchema

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

Definition at line 50 of file MemProf.h.

Enumeration Type Documentation

◆ IndexedVersion

Enumerator
Version0 
Version1 
Version2 
Version3 

Definition at line 24 of file MemProf.h.

◆ Meta

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

Definition at line 42 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(), and llvm::Type::getInt64Ty().

Referenced by addCallsiteMetadata(), and createMIBNode().

◆ computeFrameHistogram()

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

Definition at line 616 of file MemProf.cpp.

References E, and I.

Referenced by writeMemProfV3().

◆ deserializeV0()

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

◆ 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

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

References assert(), and llvm_unreachable.

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

◆ getFullSchema()

MemProfSchema llvm::memprof::getFullSchema ( )

Definition at line 13 of file MemProf.cpp.

References llvm::List.

Referenced by writeMemProfV0(), writeMemProfV1(), writeMemProfV2(), and writeMemProfV3().

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

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

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

◆ getMIBTotalSize()

uint64_t llvm::memprof::getMIBTotalSize ( const MDNode MIB)

Returns the total size from an MIB metadata node, or 0 if it was not recorded.

Definition at line 102 of file MemoryProfileInfo.cpp.

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

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

◆ hashCallStack()

CallStackId llvm::memprof::hashCallStack ( ArrayRef< FrameId CS)

◆ hasSingleAllocType()

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

True if the AllocTypes bitmask contains just a single type.

Definition at line 132 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 376 of file MemProf.cpp.

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

◆ serializedSizeV0() [1/2]

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

◆ serializedSizeV0() [2/2]

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

Definition at line 72 of file MemProf.cpp.

References N, and Version0.

◆ 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 89 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 103 of file MemProf.cpp.

References N, and Version3.

◆ serializeV0()

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

Definition at line 131 of file MemProf.cpp.

References llvm::little, N, and OS.

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

◆ serializeV2()

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

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

◆ verifyFunctionProfileData()

void llvm::memprof::verifyFunctionProfileData ( const llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > &  FunctionProfileData)

Definition at line 638 of file MemProf.cpp.

References verifyIndexedMemProfRecord().

◆ verifyIndexedMemProfRecord()

void llvm::memprof::verifyIndexedMemProfRecord ( const IndexedMemProfRecord Record)

Definition at line 631 of file MemProf.cpp.

References assert(), and hashCallStack().

Referenced by verifyFunctionProfileData().

Variable Documentation

◆ MaximumSupportedVersion

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

◆ MinimumSupportedVersion

constexpr uint64_t llvm::memprof::MinimumSupportedVersion = Version0
constexpr