LLVM 19.0.0git
MemProf.h
Go to the documentation of this file.
1#ifndef LLVM_PROFILEDATA_MEMPROF_H_
2#define LLVM_PROFILEDATA_MEMPROF_H_
3
12
13#include <cstdint>
14#include <optional>
15
16namespace llvm {
17namespace memprof {
18
19// The versions of the indexed MemProf format
21 // Version 0: This version didn't have a version field.
23 // Version 1: Added a version field to the header.
25 // Version 2: Added a call stack table. Under development.
27};
28
31
32// Verify that the minimum and maximum satisfy the obvious constraint.
34
35enum class Meta : uint64_t {
36 Start = 0,
37#define MIBEntryDef(NameTag, Name, Type) NameTag,
39#undef MIBEntryDef
40 Size
41};
42
44
45// Holds the actual MemInfoBlock data with all fields. Contents may be read or
46// written partially by providing an appropriate schema to the serialize and
47// deserialize methods.
50 explicit PortableMemInfoBlock(const MemInfoBlock &Block) {
51#define MIBEntryDef(NameTag, Name, Type) Name = Block.Name;
53#undef MIBEntryDef
54 }
55
56 PortableMemInfoBlock(const MemProfSchema &Schema, const unsigned char *Ptr) {
57 deserialize(Schema, Ptr);
58 }
59
60 // Read the contents of \p Ptr based on the \p Schema to populate the
61 // MemInfoBlock member.
62 void deserialize(const MemProfSchema &Schema, const unsigned char *Ptr) {
63 using namespace support;
64
65 for (const Meta Id : Schema) {
66 switch (Id) {
67#define MIBEntryDef(NameTag, Name, Type) \
68 case Meta::Name: { \
69 Name = endian::readNext<Type, llvm::endianness::little, unaligned>(Ptr); \
70 } break;
72#undef MIBEntryDef
73 default:
74 llvm_unreachable("Unknown meta type id, is the profile collected from "
75 "a newer version of the runtime?");
76 }
77 }
78 }
79
80 // Write the contents of the MemInfoBlock based on the \p Schema provided to
81 // the raw_ostream \p OS.
82 void serialize(const MemProfSchema &Schema, raw_ostream &OS) const {
83 using namespace support;
84
86 for (const Meta Id : Schema) {
87 switch (Id) {
88#define MIBEntryDef(NameTag, Name, Type) \
89 case Meta::Name: { \
90 LE.write<Type>(Name); \
91 } break;
93#undef MIBEntryDef
94 default:
95 llvm_unreachable("Unknown meta type id, invalid input?");
96 }
97 }
98 }
99
100 // Print out the contents of the MemInfoBlock in YAML format.
101 void printYAML(raw_ostream &OS) const {
102 OS << " MemInfoBlock:\n";
103#define MIBEntryDef(NameTag, Name, Type) \
104 OS << " " << #Name << ": " << Name << "\n";
106#undef MIBEntryDef
107 }
108
109 // Define getters for each type which can be called by analyses.
110#define MIBEntryDef(NameTag, Name, Type) \
111 Type get##Name() const { return Name; }
113#undef MIBEntryDef
114
115 void clear() { *this = PortableMemInfoBlock(); }
116
117 // Returns the full schema currently in use.
120#define MIBEntryDef(NameTag, Name, Type) List.push_back(Meta::Name);
122#undef MIBEntryDef
123 return List;
124 }
125
127#define MIBEntryDef(NameTag, Name, Type) \
128 if (Other.get##Name() != get##Name()) \
129 return false;
131#undef MIBEntryDef
132 return true;
133 }
134
136 return !operator==(Other);
137 }
138
139 static constexpr size_t serializedSize() {
140 size_t Result = 0;
141#define MIBEntryDef(NameTag, Name, Type) Result += sizeof(Type);
143#undef MIBEntryDef
144 return Result;
145 }
146
147private:
148#define MIBEntryDef(NameTag, Name, Type) Type Name = Type();
150#undef MIBEntryDef
151};
152
153// A type representing the id generated by hashing the contents of the Frame.
155// Describes a call frame for a dynamic allocation context. The contents of
156// the frame are populated by symbolizing the stack depot call frame from the
157// compiler runtime.
158struct Frame {
159 // A uuid (uint64_t) identifying the function. It is obtained by
160 // llvm::md5(FunctionName) which returns the lower 64 bits.
162 // The symbol name for the function. Only populated in the Frame by the reader
163 // if requested during initialization. This field should not be serialized.
164 std::optional<std::string> SymbolName;
165 // The source line offset of the call from the beginning of parent function.
167 // The source column number of the call to help distinguish multiple calls
168 // on the same line.
170 // Whether the current frame is inlined.
172
173 Frame(const Frame &Other) {
174 Function = Other.Function;
175 SymbolName = Other.SymbolName;
176 LineOffset = Other.LineOffset;
177 Column = Other.Column;
178 IsInlineFrame = Other.IsInlineFrame;
179 }
180
181 Frame(uint64_t Hash, uint32_t Off, uint32_t Col, bool Inline)
182 : Function(Hash), LineOffset(Off), Column(Col), IsInlineFrame(Inline) {}
183
184 bool operator==(const Frame &Other) const {
185 // Ignore the SymbolName field to avoid a string compare. Comparing the
186 // function hash serves the same purpose.
187 return Other.Function == Function && Other.LineOffset == LineOffset &&
188 Other.Column == Column && Other.IsInlineFrame == IsInlineFrame;
189 }
190
192 Function = Other.Function;
193 SymbolName = Other.SymbolName;
194 LineOffset = Other.LineOffset;
195 Column = Other.Column;
196 IsInlineFrame = Other.IsInlineFrame;
197 return *this;
198 }
199
200 bool operator!=(const Frame &Other) const { return !operator==(Other); }
201
202 // Write the contents of the frame to the ostream \p OS.
203 void serialize(raw_ostream &OS) const {
204 using namespace support;
205
207
208 // If the type of the GlobalValue::GUID changes, then we need to update
209 // the reader and the writer.
210 static_assert(std::is_same<GlobalValue::GUID, uint64_t>::value,
211 "Expect GUID to be uint64_t.");
212 LE.write<uint64_t>(Function);
213
214 LE.write<uint32_t>(LineOffset);
215 LE.write<uint32_t>(Column);
216 LE.write<bool>(IsInlineFrame);
217 }
218
219 // Read a frame from char data which has been serialized as little endian.
220 static Frame deserialize(const unsigned char *Ptr) {
221 using namespace support;
222
223 const uint64_t F =
224 endian::readNext<uint64_t, llvm::endianness::little, unaligned>(Ptr);
225 const uint32_t L =
226 endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Ptr);
227 const uint32_t C =
228 endian::readNext<uint32_t, llvm::endianness::little, unaligned>(Ptr);
229 const bool I =
230 endian::readNext<bool, llvm::endianness::little, unaligned>(Ptr);
231 return Frame(/*Function=*/F, /*LineOffset=*/L, /*Column=*/C,
232 /*IsInlineFrame=*/I);
233 }
234
235 // Returns the size of the frame information.
236 static constexpr size_t serializedSize() {
237 return sizeof(Frame::Function) + sizeof(Frame::LineOffset) +
238 sizeof(Frame::Column) + sizeof(Frame::IsInlineFrame);
239 }
240
241 // Print the frame information in YAML format.
242 void printYAML(raw_ostream &OS) const {
243 OS << " -\n"
244 << " Function: " << Function << "\n"
245 << " SymbolName: " << SymbolName.value_or("<None>") << "\n"
246 << " LineOffset: " << LineOffset << "\n"
247 << " Column: " << Column << "\n"
248 << " Inline: " << IsInlineFrame << "\n";
249 }
250
251 // Return a hash value based on the contents of the frame. Here we don't use
252 // hashing from llvm ADT since we are going to persist the hash id, the hash
253 // combine algorithm in ADT uses a new randomized seed each time.
254 inline FrameId hash() const {
255 auto HashCombine = [](auto Value, size_t Seed) {
256 std::hash<decltype(Value)> Hasher;
257 // The constant used below is the 64 bit representation of the fractional
258 // part of the golden ratio. Used here for the randomness in their bit
259 // pattern.
260 return Hasher(Value) + 0x9e3779b97f4a7c15 + (Seed << 6) + (Seed >> 2);
261 };
262
263 size_t Result = 0;
264 Result ^= HashCombine(Function, Result);
265 Result ^= HashCombine(LineOffset, Result);
266 Result ^= HashCombine(Column, Result);
267 Result ^= HashCombine(IsInlineFrame, Result);
268 return static_cast<FrameId>(Result);
269 }
270};
271
272// A type representing the index into the table of call stacks.
274
275// Holds allocation information in a space efficient format where frames are
276// represented using unique identifiers.
278 // The dynamic calling context for the allocation in bottom-up (leaf-to-root)
279 // order. Frame contents are stored out-of-line.
280 // TODO: Remove once we fully transition to CSId.
282 // Conceptually the same as above. We are going to keep both CallStack and
283 // CallStackId while we are transitioning from CallStack to CallStackId.
285 // The statistics obtained from the runtime for the allocation.
287
290 const MemInfoBlock &MB)
291 : CallStack(CS.begin(), CS.end()), CSId(CSId), Info(MB) {}
292
293 // Returns the size in bytes when this allocation info struct is serialized.
294 size_t serializedSize(IndexedVersion Version) const;
295
297 if (Other.Info != Info)
298 return false;
299
300 if (Other.CSId != CSId)
301 return false;
302 return true;
303 }
304
306 return !operator==(Other);
307 }
308};
309
310// Holds allocation information with frame contents inline. The type should
311// be used for temporary in-memory instances.
313 // Same as IndexedAllocationInfo::CallStack with the frame contents inline.
315 // Same as IndexedAllocationInfo::Info;
317
318 AllocationInfo() = default;
320 const IndexedAllocationInfo &IndexedAI,
321 llvm::function_ref<const Frame(const FrameId)> IdToFrameCallback) {
322 for (const FrameId &Id : IndexedAI.CallStack) {
323 CallStack.push_back(IdToFrameCallback(Id));
324 }
325 Info = IndexedAI.Info;
326 }
327
328 void printYAML(raw_ostream &OS) const {
329 OS << " -\n";
330 OS << " Callstack:\n";
331 // TODO: Print out the frame on one line with to make it easier for deep
332 // callstacks once we have a test to check valid YAML is generated.
333 for (const Frame &F : CallStack) {
334 F.printYAML(OS);
335 }
337 }
338};
339
340// Holds the memprof profile information for a function. The internal
341// representation stores frame ids for efficiency. This representation should
342// be used in the profile conversion and manipulation tools.
344 // Memory allocation sites in this function for which we have memory
345 // profiling data.
347 // Holds call sites in this function which are part of some memory
348 // allocation context. We store this as a list of locations, each with its
349 // list of inline locations in bottom-up order i.e. from leaf to root. The
350 // inline location list may include additional entries, users should pick
351 // the last entry in the list with the same function GUID.
353 // Conceptually the same as above. We are going to keep both CallSites and
354 // CallSiteIds while we are transitioning from CallSites to CallSiteIds.
356
357 void clear() {
358 AllocSites.clear();
359 CallSites.clear();
360 }
361
363 // TODO: Filter out duplicates which may occur if multiple memprof
364 // profiles are merged together using llvm-profdata.
365 AllocSites.append(Other.AllocSites);
366 CallSites.append(Other.CallSites);
367 }
368
369 size_t serializedSize(IndexedVersion Version) const;
370
372 if (Other.AllocSites.size() != AllocSites.size())
373 return false;
374
375 for (size_t I = 0; I < AllocSites.size(); I++) {
376 if (AllocSites[I] != Other.AllocSites[I])
377 return false;
378 }
379
380 if (Other.CallSiteIds != CallSiteIds)
381 return false;
382 return true;
383 }
384
385 // Serializes the memprof records in \p Records to the ostream \p OS based
386 // on the schema provided in \p Schema.
387 void serialize(const MemProfSchema &Schema, raw_ostream &OS,
388 IndexedVersion Version);
389
390 // Deserializes memprof records from the Buffer.
392 const unsigned char *Buffer,
393 IndexedVersion Version);
394
395 // Returns the GUID for the function name after canonicalization. For
396 // memprof, we remove any .llvm suffix added by LTO. MemProfRecords are
397 // mapped to functions using this GUID.
398 static GlobalValue::GUID getGUID(const StringRef FunctionName);
399};
400
401// Holds the memprof profile information for a function. The internal
402// representation stores frame contents inline. This representation should
403// be used for small amount of temporary, in memory instances.
405 // Same as IndexedMemProfRecord::AllocSites with frame contents inline.
407 // Same as IndexedMemProfRecord::CallSites with frame contents inline.
409
410 MemProfRecord() = default;
413 llvm::function_ref<const Frame(const FrameId Id)> IdToFrameCallback) {
414 for (const IndexedAllocationInfo &IndexedAI : Record.AllocSites) {
415 AllocSites.emplace_back(IndexedAI, IdToFrameCallback);
416 }
417 for (const ArrayRef<FrameId> Site : Record.CallSites) {
419 for (const FrameId Id : Site) {
420 Frames.push_back(IdToFrameCallback(Id));
421 }
422 CallSites.push_back(Frames);
423 }
424 }
425
426 // Prints out the contents of the memprof record in YAML.
428 if (!AllocSites.empty()) {
429 OS << " AllocSites:\n";
430 for (const AllocationInfo &N : AllocSites)
431 N.printYAML(OS);
432 }
433
434 if (!CallSites.empty()) {
435 OS << " CallSites:\n";
436 for (const llvm::SmallVector<Frame> &Frames : CallSites) {
437 for (const Frame &F : Frames) {
438 OS << " -\n";
439 F.printYAML(OS);
440 }
441 }
442 }
443 }
444};
445
446// Reads a memprof schema from a buffer. All entries in the buffer are
447// interpreted as uint64_t. The first entry in the buffer denotes the number of
448// ids in the schema. Subsequent entries are integers which map to memprof::Meta
449// enum class entries. After successfully reading the schema, the pointer is one
450// byte past the schema contents.
451Expected<MemProfSchema> readMemProfSchema(const unsigned char *&Buffer);
452
453// Trait for reading IndexedMemProfRecord data from the on-disk hash table.
455public:
461
464 : Version(V), Schema(S) {}
465
466 static bool EqualKey(uint64_t A, uint64_t B) { return A == B; }
467 static uint64_t GetInternalKey(uint64_t K) { return K; }
468 static uint64_t GetExternalKey(uint64_t K) { return K; }
469
471
472 static std::pair<offset_type, offset_type>
473 ReadKeyDataLength(const unsigned char *&D) {
474 using namespace support;
475
476 offset_type KeyLen =
477 endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
478 offset_type DataLen =
479 endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
480 return std::make_pair(KeyLen, DataLen);
481 }
482
483 uint64_t ReadKey(const unsigned char *D, offset_type /*Unused*/) {
484 using namespace support;
486 unaligned>(D);
487 }
488
489 data_type ReadData(uint64_t K, const unsigned char *D,
490 offset_type /*Unused*/) {
491 Record = IndexedMemProfRecord::deserialize(Schema, D, Version);
492 return Record;
493 }
494
495private:
496 // Holds the MemProf version.
497 IndexedVersion Version;
498 // Holds the memprof schema used to deserialize records.
499 MemProfSchema Schema;
500 // Holds the records from one function deserialized from the indexed format.
502};
503
504// Trait for writing IndexedMemProfRecord data to the on-disk hash table.
506public:
509
512
515
516 // Pointer to the memprof schema to use for the generator. Unlike the reader
517 // we must use a default constructor with no params for the writer trait so we
518 // have a public member which must be initialized by the user.
520 // The MemProf version to use for the serialization.
522
523 // We do not support the default constructor, which does not set Version.
526
528
529 std::pair<offset_type, offset_type>
531 using namespace support;
532
534 offset_type N = sizeof(K);
535 LE.write<offset_type>(N);
536 offset_type M = V.serializedSize(Version);
537 LE.write<offset_type>(M);
538 return std::make_pair(N, M);
539 }
540
541 void EmitKey(raw_ostream &Out, key_type_ref K, offset_type /*Unused*/) {
542 using namespace support;
544 LE.write<uint64_t>(K);
545 }
546
548 offset_type /*Unused*/) {
549 assert(Schema != nullptr && "MemProf schema is not initialized!");
550 V.serialize(*Schema, Out, Version);
551 // Clear the IndexedMemProfRecord which results in clearing/freeing its
552 // vectors of allocs and callsites. This is owned by the associated on-disk
553 // hash table, but unused after this point. See also the comment added to
554 // the client which constructs the on-disk hash table for this trait.
555 V.clear();
556 }
557};
558
559// Trait for writing frame mappings to the on-disk hash table.
561public:
564
567
570
572
573 static std::pair<offset_type, offset_type>
575 using namespace support;
577 offset_type N = sizeof(K);
578 LE.write<offset_type>(N);
579 offset_type M = V.serializedSize();
580 LE.write<offset_type>(M);
581 return std::make_pair(N, M);
582 }
583
584 void EmitKey(raw_ostream &Out, key_type_ref K, offset_type /*Unused*/) {
585 using namespace support;
587 LE.write<key_type>(K);
588 }
589
591 offset_type /*Unused*/) {
592 V.serialize(Out);
593 }
594};
595
596// Trait for reading frame mappings from the on-disk hash table.
598public:
599 using data_type = const Frame;
604
606 return A == B;
607 }
610
612
613 static std::pair<offset_type, offset_type>
614 ReadKeyDataLength(const unsigned char *&D) {
615 using namespace support;
616
617 offset_type KeyLen =
618 endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
619 offset_type DataLen =
620 endian::readNext<offset_type, llvm::endianness::little, unaligned>(D);
621 return std::make_pair(KeyLen, DataLen);
622 }
623
624 uint64_t ReadKey(const unsigned char *D, offset_type /*Unused*/) {
625 using namespace support;
627 unaligned>(D);
628 }
629
630 data_type ReadData(uint64_t K, const unsigned char *D,
631 offset_type /*Unused*/) {
632 return Frame::deserialize(D);
633 }
634};
635
636// Compute a CallStackId for a given call stack.
638
639// Verify that each CallStackId is computed with hashCallStack. This function
640// is intended to help transition from CallStack to CSId in
641// IndexedAllocationInfo.
642void verifyIndexedMemProfRecord(const IndexedMemProfRecord &Record);
643
644// Verify that each CallStackId is computed with hashCallStack. This function
645// is intended to help transition from CallStack to CSId in
646// IndexedAllocationInfo.
649 &FunctionProfileData);
650} // namespace memprof
651} // namespace llvm
652
653#endif // LLVM_PROFILEDATA_MEMPROF_H_
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define F(x, y, z)
Definition: MD5.cpp:55
#define I(x, y, z)
Definition: MD5.cpp:58
This file implements a map that provides insertion order iteration.
static ManagedStatic< cl::opt< uint64_t >, CreateSeed > Seed
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Tagged union holding either a T or a Error.
Definition: Error.h:474
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:587
This class implements a map that also provides access to all stored values in a deterministic order.
Definition: MapVector.h:36
void push_back(const T &Elt)
Definition: SmallVector.h:426
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
LLVM Value Representation.
Definition: Value.h:74
An efficient, type-erasing, non-owning reference to a callable.
Helper class to iterate through stack ids in both metadata (memprof MIB and callsite) and the corresp...
data_type ReadData(uint64_t K, const unsigned char *D, offset_type)
Definition: MemProf.h:630
static uint64_t GetExternalKey(external_key_type K)
Definition: MemProf.h:609
static bool EqualKey(internal_key_type A, internal_key_type B)
Definition: MemProf.h:605
static uint64_t GetInternalKey(internal_key_type K)
Definition: MemProf.h:608
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
Definition: MemProf.h:614
hash_value_type ComputeHash(internal_key_type K)
Definition: MemProf.h:611
uint64_t ReadKey(const unsigned char *D, offset_type)
Definition: MemProf.h:624
static hash_value_type ComputeHash(key_type_ref K)
Definition: MemProf.h:571
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
Definition: MemProf.h:584
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
Definition: MemProf.h:590
static std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
Definition: MemProf.h:574
static bool EqualKey(uint64_t A, uint64_t B)
Definition: MemProf.h:466
uint64_t ReadKey(const unsigned char *D, offset_type)
Definition: MemProf.h:483
data_type ReadData(uint64_t K, const unsigned char *D, offset_type)
Definition: MemProf.h:489
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
Definition: MemProf.h:473
static uint64_t GetInternalKey(uint64_t K)
Definition: MemProf.h:467
hash_value_type ComputeHash(uint64_t K)
Definition: MemProf.h:470
static uint64_t GetExternalKey(uint64_t K)
Definition: MemProf.h:468
RecordLookupTrait(IndexedVersion V, const MemProfSchema &S)
Definition: MemProf.h:463
static hash_value_type ComputeHash(key_type_ref K)
Definition: MemProf.h:527
std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
Definition: MemProf.h:530
RecordWriterTrait(IndexedVersion V)
Definition: MemProf.h:525
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
Definition: MemProf.h:541
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
Definition: MemProf.h:547
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
void verifyIndexedMemProfRecord(const IndexedMemProfRecord &Record)
Definition: MemProf.cpp:278
constexpr uint64_t MaximumSupportedVersion
Definition: MemProf.h:30
CallStackId hashCallStack(ArrayRef< FrameId > CS)
Definition: MemProf.cpp:267
uint64_t FrameId
Definition: MemProf.h:154
constexpr uint64_t MinimumSupportedVersion
Definition: MemProf.h:29
uint64_t CallStackId
Definition: MemProf.h:273
Expected< MemProfSchema > readMemProfSchema(const unsigned char *&Buffer)
Definition: MemProf.cpp:241
void verifyFunctionProfileData(const llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > &FunctionProfileData)
Definition: MemProf.cpp:285
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.
Definition: Endian.h:76
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Other
Any other memory.
#define N
AllocationInfo(const IndexedAllocationInfo &IndexedAI, llvm::function_ref< const Frame(const FrameId)> IdToFrameCallback)
Definition: MemProf.h:319
PortableMemInfoBlock Info
Definition: MemProf.h:316
llvm::SmallVector< Frame > CallStack
Definition: MemProf.h:314
void printYAML(raw_ostream &OS) const
Definition: MemProf.h:328
Frame & operator=(const Frame &Other)
Definition: MemProf.h:191
Frame(const Frame &Other)
Definition: MemProf.h:173
static constexpr size_t serializedSize()
Definition: MemProf.h:236
void printYAML(raw_ostream &OS) const
Definition: MemProf.h:242
GlobalValue::GUID Function
Definition: MemProf.h:161
void serialize(raw_ostream &OS) const
Definition: MemProf.h:203
std::optional< std::string > SymbolName
Definition: MemProf.h:164
Frame(uint64_t Hash, uint32_t Off, uint32_t Col, bool Inline)
Definition: MemProf.h:181
bool operator==(const Frame &Other) const
Definition: MemProf.h:184
bool operator!=(const Frame &Other) const
Definition: MemProf.h:200
static Frame deserialize(const unsigned char *Ptr)
Definition: MemProf.h:220
FrameId hash() const
Definition: MemProf.h:254
uint32_t LineOffset
Definition: MemProf.h:166
bool operator==(const IndexedAllocationInfo &Other) const
Definition: MemProf.h:296
bool operator!=(const IndexedAllocationInfo &Other) const
Definition: MemProf.h:305
PortableMemInfoBlock Info
Definition: MemProf.h:286
llvm::SmallVector< FrameId > CallStack
Definition: MemProf.h:281
size_t serializedSize(IndexedVersion Version) const
Definition: MemProf.cpp:33
IndexedAllocationInfo(ArrayRef< FrameId > CS, CallStackId CSId, const MemInfoBlock &MB)
Definition: MemProf.h:289
llvm::SmallVector< CallStackId > CallSiteIds
Definition: MemProf.h:355
llvm::SmallVector< IndexedAllocationInfo > AllocSites
Definition: MemProf.h:346
static IndexedMemProfRecord deserialize(const MemProfSchema &Schema, const unsigned char *Buffer, IndexedVersion Version)
Definition: MemProf.cpp:212
llvm::SmallVector< llvm::SmallVector< FrameId > > CallSites
Definition: MemProf.h:352
size_t serializedSize(IndexedVersion Version) const
Definition: MemProf.cpp:71
bool operator==(const IndexedMemProfRecord &Other) const
Definition: MemProf.h:371
void serialize(const MemProfSchema &Schema, raw_ostream &OS, IndexedVersion Version)
Definition: MemProf.cpp:123
static GlobalValue::GUID getGUID(const StringRef FunctionName)
Definition: MemProf.cpp:225
void merge(const IndexedMemProfRecord &Other)
Definition: MemProf.h:362
llvm::SmallVector< AllocationInfo > AllocSites
Definition: MemProf.h:406
void print(llvm::raw_ostream &OS) const
Definition: MemProf.h:427
MemProfRecord(const IndexedMemProfRecord &Record, llvm::function_ref< const Frame(const FrameId Id)> IdToFrameCallback)
Definition: MemProf.h:411
llvm::SmallVector< llvm::SmallVector< Frame > > CallSites
Definition: MemProf.h:408
bool operator!=(const PortableMemInfoBlock &Other) const
Definition: MemProf.h:135
PortableMemInfoBlock(const MemInfoBlock &Block)
Definition: MemProf.h:50
PortableMemInfoBlock(const MemProfSchema &Schema, const unsigned char *Ptr)
Definition: MemProf.h:56
static MemProfSchema getSchema()
Definition: MemProf.h:118
void deserialize(const MemProfSchema &Schema, const unsigned char *Ptr)
Definition: MemProf.h:62
static constexpr size_t serializedSize()
Definition: MemProf.h:139
void printYAML(raw_ostream &OS) const
Definition: MemProf.h:101
void serialize(const MemProfSchema &Schema, raw_ostream &OS) const
Definition: MemProf.h:82
bool operator==(const PortableMemInfoBlock &Other) const
Definition: MemProf.h:126
Adapter to write values to a stream in a particular byte order.
Definition: EndianStream.h:67