13#define MIBEntryDef(NameTag, Name, Type) List.push_back(Meta::Name);
20 return {Meta::AllocCount, Meta::TotalSize, Meta::TotalLifetime,
21 Meta::TotalLifetimeAccessDensity};
50 Result +=
N.serializedSize(Schema,
Version3);
65 Result +=
N.serializedSize(Schema,
Version4);
69 for (
const auto &CS :
Record.CallSites)
98 N.Info.serialize(Schema, OS);
103 for (
const auto &CS :
Record.CallSites) {
121 N.Info.serialize(Schema, OS);
126 for (
const auto &CS :
Record.CallSites) {
129 LE.write<
uint64_t>(CS.CalleeGuids.size());
130 for (
const auto &
Guid : CS.CalleeGuids)
141 serializeV3(*
this, Schema, OS, *MemProfCallStackIndexes);
144 serializeV4(*
this, Schema, OS, *MemProfCallStackIndexes);
151 const unsigned char *Ptr) {
159 Record.AllocSites.reserve(NumNodes);
165 Node.Info.deserialize(Schema, Ptr);
166 Ptr += SerializedSize;
173 Record.CallSites.reserve(NumCtxs);
174 for (
uint64_t J = 0; J < NumCtxs; J++) {
181 Record.CallSites.emplace_back(CSId);
188 const unsigned char *Ptr) {
196 Record.AllocSites.reserve(NumNodes);
202 Node.Info.deserialize(Schema, Ptr);
203 Ptr += SerializedSize;
210 Record.CallSites.reserve(NumCtxs);
211 for (
uint64_t J = 0; J < NumCtxs; J++) {
222 Record.CallSites.emplace_back(CSId, std::move(Guids));
230 const unsigned char *Ptr,
248 AI.
Info = IndexedAI.Info;
250 Record.AllocSites.push_back(std::move(AI));
255 std::vector<Frame> Frames = Callback(CS.CSId);
256 Record.CallSites.emplace_back(std::move(Frames), CS.CalleeGuids);
281 const unsigned char *Ptr = Buffer;
284 if (NumSchemaIds >
static_cast<uint64_t>(Meta::Size)) {
286 "memprof schema invalid");
290 for (
size_t I = 0;
I < NumSchemaIds;
I++) {
295 "memprof schema invalid");
297 Result.push_back(
static_cast<Meta>(
Tag));
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the SmallVector class.
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Tagged union holding either a T or a Error.
static LLVM_ABI GUID getGUIDAssumingExternalLinkage(StringRef GlobalName)
Return a 64-bit global unique ID constructed from the name of a global symbol.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
static StringRef getCanonicalFnName(const Function &F)
Return the canonical name for a function, taking into account suffix elision policy attributes.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static IndexedMemProfRecord deserializeV4(const MemProfSchema &Schema, const unsigned char *Ptr)
uint32_t LinearCallStackId
static IndexedMemProfRecord deserializeV3(const MemProfSchema &Schema, const unsigned char *Ptr)
static void serializeV3(const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS, llvm::DenseMap< CallStackId, LinearCallStackId > &MemProfCallStackIndexes)
LLVM_ABI MemProfSchema getHotColdSchema()
llvm::SmallVector< Meta, static_cast< int >(Meta::Size)> MemProfSchema
static size_t serializedSizeV3(const IndexedAllocationInfo &IAI, const MemProfSchema &Schema)
LLVM_ABI MemProfSchema getFullSchema()
LLVM_ABI GlobalValue::GUID getGUID(const StringRef FunctionName)
static void serializeV4(const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS, llvm::DenseMap< CallStackId, LinearCallStackId > &MemProfCallStackIndexes)
LLVM_ABI Expected< MemProfSchema > readMemProfSchema(const unsigned char *&Buffer)
static size_t serializedSizeV4(const IndexedMemProfRecord &Record, const MemProfSchema &Schema)
value_type readNext(const CharT *&memory, endianness endian)
Read a value of a particular endianness from a buffer, and increment the buffer past that value.
This is an optimization pass for GlobalISel generic memory operations.
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
std::vector< Frame > CallStack
PortableMemInfoBlock Info
LLVM_ABI size_t serializedSize(const MemProfSchema &Schema, IndexedVersion Version) const
llvm::SmallVector< IndexedAllocationInfo > AllocSites
LLVM_ABI size_t serializedSize(const MemProfSchema &Schema, IndexedVersion Version) const
LLVM_ABI void serialize(const MemProfSchema &Schema, raw_ostream &OS, IndexedVersion Version, llvm::DenseMap< CallStackId, LinearCallStackId > *MemProfCallStackIndexes=nullptr) const
static LLVM_ABI IndexedMemProfRecord deserialize(const MemProfSchema &Schema, const unsigned char *Buffer, IndexedVersion Version)
llvm::SmallVector< IndexedCallSiteInfo > CallSites
LLVM_ABI MemProfRecord toMemProfRecord(llvm::function_ref< std::vector< Frame >(const CallStackId)> Callback) const
static size_t serializedSize(const MemProfSchema &Schema)
Adapter to write values to a stream in a particular byte order.