13#ifndef LLVM_ANALYSIS_MEMORYPROFILEINFO_H
14#define LLVM_ANALYSIS_MEMORYPROFILEINFO_H
55 struct CallStackTrieNode {
89 bool DeepestAmbiguousAllocType =
true;
94 std::vector<ContextTotalSize> ContextSizeInfo;
96 std::map<uint64_t, CallStackTrieNode *> Callers;
103 AllocTypes &= ~static_cast<uint8_t>(
AllocType);
111 CallStackTrieNode *Alloc =
nullptr;
115 void deleteTrieNode(CallStackTrieNode *
Node) {
118 for (
auto C :
Node->Callers)
119 deleteTrieNode(
C.second);
125 void collectContextSizeInfo(CallStackTrieNode *
Node,
126 std::vector<ContextTotalSize> &ContextSizeInfo);
131 void convertHotToNotCold(CallStackTrieNode *
Node);
135 std::vector<uint64_t> &MIBCallStack,
136 std::vector<Metadata *> &MIBNodes,
137 bool CalleeHasAmbiguousCallerContext,
138 bool &CalleeDeepestAmbiguousAllocType);
144 bool empty()
const {
return Alloc ==
nullptr; }
152 std::vector<ContextTotalSize> ContextSizeInfo = {});
179template <
class NodeT,
class IteratorT>
class CallStack {
188 const NodeT *
N =
nullptr;
197 bool empty()
const {
return N ==
nullptr; }
199 CallStackIterator
begin()
const;
205 const NodeT *N =
nullptr;
208template <
class NodeT,
class IteratorT>
210 const NodeT *
N,
bool End)
216 Iter =
End ?
N->StackIdIndices.end() :
N->StackIdIndices.begin();
219template <
class NodeT,
class IteratorT>
221 assert(Iter != N->StackIdIndices.end());
225template <
class NodeT,
class IteratorT>
228 return N->StackIdIndices.back();
231template <
class NodeT,
class IteratorT>
237template <
class NodeT,
class IteratorT>
242 Cur !=
end() && OtherCur !=
Other.end(); ++Cur, ++OtherCur)
243 assert(*Cur == *OtherCur);
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
This is an important class for using LLVM in a threaded context.
StringRef - Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
Class to build a trie of call stack contexts for a particular profiled allocation call,...
void addCallStack(AllocationType AllocType, ArrayRef< uint64_t > StackIds, std::vector< ContextTotalSize > ContextSizeInfo={})
Add a call stack context with the given allocation type to the Trie.
void addSingleAllocTypeAttribute(CallBase *CI, AllocationType AT, StringRef Descriptor)
Add an attribute for the given allocation type to the call instruction.
bool buildAndAttachMIBMetadata(CallBase *CI)
Build and attach the minimal necessary MIB metadata.
Helper class to iterate through stack ids in both metadata (memprof MIB and callsite) and the corresp...
CallStack(const NodeT *N=nullptr)
CallStackIterator begin() const
CallStackIterator end() const
CallStackIterator beginAfterSharedPrefix(CallStack &Other)
@ C
The default llvm calling convention, compatible with C.
MDNode * buildCallstackMetadata(ArrayRef< uint64_t > CallStack, LLVMContext &Ctx)
Build callstack metadata from the provided list of call stack ids.
AllocationType getAllocType(uint64_t TotalLifetimeAccessDensity, uint64_t AllocCount, uint64_t TotalLifetime)
Return the allocation type for a given set of memory profile values.
MDNode * buildContextSizeMetadata(ArrayRef< ContextTotalSize > ContextSizeInfo, LLVMContext &Ctx)
Build metadata from the provided list of full stack id and profiled size, to use when reporting of hi...
AllocationType getMIBAllocType(const MDNode *MIB)
Returns the allocation type from an MIB metadata node.
bool hasSingleAllocType(uint8_t AllocTypes)
True if the AllocTypes bitmask contains just a single type.
std::string getAllocTypeAttributeString(AllocationType Type)
Returns the string to use in attributes with the given type.
MDNode * getMIBStackNode(const MDNode *MIB)
Returns the stack node from an MIB metadata node.
This is an optimization pass for GlobalISel generic memory operations.
bool operator!=(const CallStackIterator &rhs)
bool operator==(const CallStackIterator &rhs)
CallStackIterator(const NodeT *N, bool End)