LLVM 24.0.0git
MemProf.h
Go to the documentation of this file.
1//===- MemProf.h - MemProf support ------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains common definitions used in the reading and writing of
10// memory profile data.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_PROFILEDATA_MEMPROF_H
15#define LLVM_PROFILEDATA_MEMPROF_H
16
17#include "llvm/ADT/DenseMap.h"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/IR/GlobalValue.h"
25#include "llvm/Support/Endian.h"
28
29#include <bitset>
30#include <cstdint>
32namespace llvm {
33namespace yaml {
34template <typename T> struct CustomMappingTraits;
35} // namespace yaml
37namespace memprof {
41// The versions of the indexed MemProf format
43 // Version 3: Added a radix tree for call stacks. Switched to linear IDs for
44 // frames and call stacks.
46 // Version 4: Added CalleeGuids to call site info.
48};
53// Verify that the minimum and maximum satisfy the obvious constraint.
57 return "___memprof_default_options_str";
58}
59
61 // Darwin linkage names are prefixed with an extra "_". See
62 // DataLayout::getGlobalPrefix().
64}
65
66enum class Meta : uint64_t {
67 Start = 0,
68#define MIBEntryDef(NameTag, Name, Type) NameTag,
70#undef MIBEntryDef
71 Size
72};
73
75
76// Returns the full schema currently in use.
78
79// Returns the schema consisting of the fields used for hot cold memory hinting.
81
82// Holds the actual MemInfoBlock data with all fields. Contents may be read or
83// written partially by providing an appropriate schema to the serialize and
84// deserialize methods.
87 explicit PortableMemInfoBlock(const MemInfoBlock &Block,
88 const MemProfSchema &IncomingSchema) {
89 for (const Meta Id : IncomingSchema)
90 Schema.set(llvm::to_underlying(Id));
91#define MIBEntryDef(NameTag, Name, Type) Name = Block.Name;
93#undef MIBEntryDef
94 }
96 PortableMemInfoBlock(const MemProfSchema &Schema, const unsigned char *Ptr) {
97 deserialize(Schema, Ptr);
98 }
100 // Read the contents of \p Ptr based on the \p Schema to populate the
101 // MemInfoBlock member.
102 void deserialize(const MemProfSchema &IncomingSchema,
103 const unsigned char *Ptr) {
104 using namespace support;
106 Schema.reset();
107 for (const Meta Id : IncomingSchema) {
108 switch (Id) {
109#define MIBEntryDef(NameTag, Name, Type) \
110 case Meta::Name: { \
111 Name = endian::readNext<Type, llvm::endianness::little>(Ptr); \
112 } break;
114#undef MIBEntryDef
115 default:
116 llvm_unreachable("Unknown meta type id, is the profile collected from "
117 "a newer version of the runtime?");
120 Schema.set(llvm::to_underlying(Id));
122 }
123
124 // Write the contents of the MemInfoBlock based on the \p Schema provided to
125 // the raw_ostream \p OS.
126 void serialize(const MemProfSchema &Schema, raw_ostream &OS) const {
127 using namespace support;
128
130 for (const Meta Id : Schema) {
131 switch (Id) {
132#define MIBEntryDef(NameTag, Name, Type) \
133 case Meta::Name: { \
134 LE.write<Type>(Name); \
135 } break;
137#undef MIBEntryDef
138 default:
139 llvm_unreachable("Unknown meta type id, invalid input?");
140 }
141 }
142 }
143
144 // Print out the contents of the MemInfoBlock in YAML format.
145 void printYAML(raw_ostream &OS) const {
146 OS << " MemInfoBlock:\n";
147#define MIBEntryDef(NameTag, Name, Type) \
148 OS << " " << #Name << ": " << Name << "\n";
150#undef MIBEntryDef
151 if (AccessHistogramSize > 0) {
152 OS << " " << "AccessHistogramValues" << ":";
153 for (uint32_t I = 0; I < AccessHistogramSize; ++I) {
154 OS << " " << ((uint64_t *)AccessHistogram)[I];
155 }
156 OS << "\n";
157 }
158 }
159
160 // Return the schema, only for unit tests.
161 std::bitset<llvm::to_underlying(Meta::Size)> getSchema() const {
162 return Schema;
163 }
164
165 // Define getters for each type which can be called by analyses.
166#define MIBEntryDef(NameTag, Name, Type) \
167 Type get##Name() const { \
168 assert(Schema[llvm::to_underlying(Meta::Name)]); \
169 return Name; \
170 }
172#undef MIBEntryDef
173
174 // Define setters for each type which can be called by the writer.
175#define MIBEntryDef(NameTag, Name, Type) \
176 void set##Name(Type NewVal) { \
177 assert(Schema[llvm::to_underlying(Meta::Name)]); \
178 Name = NewVal; \
179 }
181#undef MIBEntryDef
182
183 void clear() { *this = PortableMemInfoBlock(); }
184
186 if (Other.Schema != Schema)
187 return false;
188
189#define MIBEntryDef(NameTag, Name, Type) \
190 if (Schema[llvm::to_underlying(Meta::Name)] && \
191 Other.get##Name() != get##Name()) \
192 return false;
194#undef MIBEntryDef
195 return true;
196 }
197
199 return !operator==(Other);
200 }
201
202 static size_t serializedSize(const MemProfSchema &Schema) {
203 size_t Result = 0;
204
205 for (const Meta Id : Schema) {
206 switch (Id) {
207#define MIBEntryDef(NameTag, Name, Type) \
208 case Meta::Name: { \
209 Result += sizeof(Type); \
210 } break;
212#undef MIBEntryDef
213 default:
214 llvm_unreachable("Unknown meta type id, invalid input?");
215 }
216 }
217
218 return Result;
219 }
220
221 // Give YAML access to the individual MIB fields.
223
224private:
225 // The set of available fields, indexed by Meta::Name.
226 std::bitset<llvm::to_underlying(Meta::Size)> Schema;
227
228#define MIBEntryDef(NameTag, Name, Type) Type Name = Type();
229#include "llvm/ProfileData/MIBEntryDef.inc"
230#undef MIBEntryDef
231};
232
233// A type representing the id generated by hashing the contents of the Frame.
235// A type representing the id to index into the frame array.
237// Describes a call frame for a dynamic allocation context. The contents of
238// the frame are populated by symbolizing the stack depot call frame from the
239// compiler runtime.
240struct Frame {
241 // A uuid (uint64_t) identifying the function. It is obtained by
242 // llvm::md5(FunctionName) which returns the lower 64 bits.
244 // The symbol name for the function. Only populated in the Frame by the reader
245 // if requested during initialization. This field should not be serialized.
246 std::unique_ptr<std::string> SymbolName;
247 // The source line offset of the call from the beginning of parent function.
249 // The source column number of the call to help distinguish multiple calls
250 // on the same line.
252 // Whether the current frame is inlined.
253 bool IsInlineFrame = false;
254
255 Frame() = default;
256 Frame(Frame &&) = default;
257 Frame &operator=(Frame &&) = default;
258
259 Frame(const Frame &Other) {
260 Function = Other.Function;
261 SymbolName = Other.SymbolName
262 ? std::make_unique<std::string>(*Other.SymbolName)
263 : nullptr;
264 LineOffset = Other.LineOffset;
265 Column = Other.Column;
266 IsInlineFrame = Other.IsInlineFrame;
267 }
268
269 Frame(GlobalValue::GUID Hash, uint32_t Off, uint32_t Col, bool Inline)
270 : Function(Hash), LineOffset(Off), Column(Col), IsInlineFrame(Inline) {}
271
272 bool operator==(const Frame &Other) const {
273 // Ignore the SymbolName field to avoid a string compare. Comparing the
274 // function hash serves the same purpose.
275 return Other.Function == Function && Other.LineOffset == LineOffset &&
276 Other.Column == Column && Other.IsInlineFrame == IsInlineFrame;
277 }
278
280 Function = Other.Function;
281 SymbolName = Other.SymbolName
282 ? std::make_unique<std::string>(*Other.SymbolName)
283 : nullptr;
284 LineOffset = Other.LineOffset;
285 Column = Other.Column;
286 IsInlineFrame = Other.IsInlineFrame;
287 return *this;
288 }
289
290 bool operator!=(const Frame &Other) const { return !operator==(Other); }
291
292 bool hasSymbolName() const { return !!SymbolName; }
293
296 return *SymbolName;
297 }
298
299 std::string getSymbolNameOr(StringRef Alt) const {
300 return std::string(hasSymbolName() ? getSymbolName() : Alt);
301 }
302
303 // Write the contents of the frame to the ostream \p OS.
304 void serialize(raw_ostream &OS) const {
305 using namespace support;
306
308
309 // If the type of the GlobalValue::GUID changes, then we need to update
310 // the reader and the writer.
311 static_assert(std::is_same<GlobalValue::GUID, uint64_t>::value,
312 "Expect GUID to be uint64_t.");
313 LE.write<uint64_t>(Function);
314
315 LE.write<uint32_t>(LineOffset);
316 LE.write<uint32_t>(Column);
317 LE.write<bool>(IsInlineFrame);
318 }
319
320 // Read a frame from char data which has been serialized as little endian.
321 static Frame deserialize(const unsigned char *Ptr) {
322 using namespace support;
323
324 const uint64_t F =
326 const uint32_t L =
328 const uint32_t C =
331 return Frame(/*Function=*/F, /*LineOffset=*/L, /*Column=*/C,
332 /*IsInlineFrame=*/I);
333 }
334
335 // Returns the size of the frame information.
336 static constexpr size_t serializedSize() {
337 return sizeof(Frame::Function) + sizeof(Frame::LineOffset) +
338 sizeof(Frame::Column) + sizeof(Frame::IsInlineFrame);
339 }
340
341 // Print the frame information in YAML format.
342 void printYAML(raw_ostream &OS) const {
343 OS << " -\n"
344 << " Function: " << Function << "\n"
345 << " SymbolName: " << getSymbolNameOr("<None>") << "\n"
346 << " LineOffset: " << LineOffset << "\n"
347 << " Column: " << Column << "\n"
348 << " Inline: " << IsInlineFrame << "\n";
349 }
350};
351
352// A type representing the index into the table of call stacks.
354
355// A type representing the index into the call stack array.
357
358// Holds call site information with indexed frame contents.
360 // The call stack ID for this call site
362 // The GUIDs of the callees at this call site
364
370
372 return CSId == Other.CSId && CalleeGuids == Other.CalleeGuids;
373 }
374
376 return !operator==(Other);
377 }
378};
379
380// Holds allocation information in a space efficient format where frames are
381// represented using unique identifiers.
383 // The dynamic calling context for the allocation in bottom-up (leaf-to-root)
384 // order. Frame contents are stored out-of-line.
386 // The statistics obtained from the runtime for the allocation.
388
390 IndexedAllocationInfo(CallStackId CSId, const MemInfoBlock &MB,
391 const MemProfSchema &Schema = getFullSchema())
392 : CSId(CSId), Info(MB, Schema) {}
395
396 // Returns the size in bytes when this allocation info struct is serialized.
397 LLVM_ABI size_t serializedSize(const MemProfSchema &Schema,
398 IndexedVersion Version) const;
399
401 if (Other.Info != Info)
402 return false;
403
404 if (Other.CSId != CSId)
405 return false;
406 return true;
407 }
408
410 return !operator==(Other);
411 }
412};
413
414// Holds allocation information with frame contents inline. The type should
415// be used for temporary in-memory instances.
417 // Same as IndexedAllocationInfo::CallStack with the frame contents inline.
418 std::vector<Frame> CallStack;
419 // Same as IndexedAllocationInfo::Info;
421
422 AllocationInfo() = default;
423
424 void printYAML(raw_ostream &OS) const {
425 OS << " -\n";
426 OS << " Callstack:\n";
427 // TODO: Print out the frame on one line with to make it easier for deep
428 // callstacks once we have a test to check valid YAML is generated.
429 for (const Frame &F : CallStack) {
430 F.printYAML(OS);
431 }
432 Info.printYAML(OS);
433 }
434};
435
436// Holds the memprof profile information for a function. The internal
437// representation stores frame ids for efficiency. This representation should
438// be used in the profile conversion and manipulation tools.
440 // Memory allocation sites in this function for which we have memory
441 // profiling data.
443 // Holds call sites in this function which are part of some memory
444 // allocation context. We store this as a list of locations, each with its
445 // list of inline locations in bottom-up order i.e. from leaf to root. The
446 // inline location list may include additional entries, users should pick
447 // the last entry in the list with the same function GUID.
449
450 void clear() { *this = IndexedMemProfRecord(); }
451
453 // TODO: Filter out duplicates which may occur if multiple memprof
454 // profiles are merged together using llvm-profdata.
455 AllocSites.append(Other.AllocSites);
456 }
457
458 LLVM_ABI size_t serializedSize(const MemProfSchema &Schema,
459 IndexedVersion Version) const;
460
462 if (Other.AllocSites != AllocSites)
463 return false;
464
465 if (Other.CallSites != CallSites)
466 return false;
467 return true;
468 }
469
470 // Serializes the memprof records in \p Records to the ostream \p OS based
471 // on the schema provided in \p Schema.
472 LLVM_ABI void serialize(const MemProfSchema &Schema, raw_ostream &OS,
475 *MemProfCallStackIndexes = nullptr) const;
476
477 // Deserializes memprof records from the Buffer.
478 LLVM_ABI static IndexedMemProfRecord deserialize(const MemProfSchema &Schema,
479 const unsigned char *Buffer,
481
482 // Convert IndexedMemProfRecord to MemProfRecord. Callback is used to
483 // translate CallStackId to call stacks with frames inline.
484 LLVM_ABI MemProfRecord toMemProfRecord(
485 llvm::function_ref<std::vector<Frame>(const CallStackId)> Callback) const;
486};
487
488// Returns the GUID for the function name after canonicalization. For
489// memprof, we remove any .llvm suffix added by LTO. MemProfRecords are
490// mapped to functions using this GUID.
491LLVM_ABI GlobalValue::GUID getGUID(const StringRef FunctionName);
492
493// Holds call site information with frame contents inline.
495 // The frames in the call stack
496 std::vector<Frame> Frames;
497
498 // The GUIDs of the callees at this call site
500
501 CallSiteInfo() = default;
502 CallSiteInfo(std::vector<Frame> Frames) : Frames(std::move(Frames)) {}
506
507 bool operator==(const CallSiteInfo &Other) const {
508 return Frames == Other.Frames && CalleeGuids == Other.CalleeGuids;
509 }
510
511 bool operator!=(const CallSiteInfo &Other) const {
512 return !operator==(Other);
513 }
514};
515
516// Holds the memprof profile information for a function. The internal
517// representation stores frame contents inline. This representation should
518// be used for small amount of temporary, in memory instances.
520 // Same as IndexedMemProfRecord::AllocSites with frame contents inline.
522 // Same as IndexedMemProfRecord::CallSites with frame contents inline.
524
525 MemProfRecord() = default;
526
527 // Prints out the contents of the memprof record in YAML.
528 void print(llvm::raw_ostream &OS) const {
529 if (!AllocSites.empty()) {
530 OS << " AllocSites:\n";
531 for (const AllocationInfo &N : AllocSites)
532 N.printYAML(OS);
533 }
534
535 if (!CallSites.empty()) {
536 OS << " CallSites:\n";
537 for (const CallSiteInfo &CS : CallSites) {
538 for (const Frame &F : CS.Frames) {
539 OS << " -\n";
540 F.printYAML(OS);
541 }
542 }
543 }
544 }
545};
546
547// Reads a memprof schema from a buffer. All entries in the buffer are
548// interpreted as uint64_t. The first entry in the buffer denotes the number of
549// ids in the schema. Subsequent entries are integers which map to memprof::Meta
550// enum class entries. After successfully reading the schema, the pointer is one
551// byte past the schema contents.
553readMemProfSchema(const unsigned char *&Buffer);
554
555// Trait for reading IndexedMemProfRecord data from the on-disk hash table.
557public:
563
566 : Version(V), Schema(S) {}
567
568 static bool EqualKey(uint64_t A, uint64_t B) { return A == B; }
569 static uint64_t GetInternalKey(uint64_t K) { return K; }
570 static uint64_t GetExternalKey(uint64_t K) { return K; }
571
573
574 static std::pair<offset_type, offset_type>
575 ReadKeyDataLength(const unsigned char *&D) {
576 using namespace support;
577
578 offset_type KeyLen =
580 offset_type DataLen =
582 return std::make_pair(KeyLen, DataLen);
583 }
584
585 uint64_t ReadKey(const unsigned char *D, offset_type /*Unused*/) {
586 using namespace support;
588 }
589
590 data_type ReadData(uint64_t K, const unsigned char *D,
591 offset_type /*Unused*/) {
592 Record = IndexedMemProfRecord::deserialize(Schema, D, Version);
593 return Record;
594 }
595
596private:
597 // Holds the MemProf version.
599 // Holds the memprof schema used to deserialize records.
600 MemProfSchema Schema;
601 // Holds the records from one function deserialized from the indexed format.
603};
604
605// Trait for writing IndexedMemProfRecord data to the on-disk hash table.
607public:
610
613
616
617private:
618 // Pointer to the memprof schema to use for the generator.
619 const MemProfSchema *Schema;
620 // The MemProf version to use for the serialization.
621 IndexedVersion Version;
622
623 // Mappings from CallStackId to the indexes into the call stack array.
624 llvm::DenseMap<CallStackId, LinearCallStackId> *MemProfCallStackIndexes;
625
626public:
627 // We do not support the default constructor, which does not set Version.
630 const MemProfSchema *Schema, IndexedVersion V,
631 llvm::DenseMap<CallStackId, LinearCallStackId> *MemProfCallStackIndexes)
632 : Schema(Schema), Version(V),
633 MemProfCallStackIndexes(MemProfCallStackIndexes) {}
634
636
637 std::pair<offset_type, offset_type>
639 using namespace support;
640
642 offset_type N = sizeof(K);
643 LE.write<offset_type>(N);
644 offset_type M = V.serializedSize(*Schema, Version);
645 LE.write<offset_type>(M);
646 return std::make_pair(N, M);
647 }
648
649 void EmitKey(raw_ostream &Out, key_type_ref K, offset_type /*Unused*/) {
650 using namespace support;
652 LE.write<uint64_t>(K);
653 }
654
656 offset_type /*Unused*/) {
657 assert(Schema != nullptr && "MemProf schema is not initialized!");
658 V.serialize(*Schema, Out, Version, MemProfCallStackIndexes);
659 // Clear the IndexedMemProfRecord which results in clearing/freeing its
660 // vectors of allocs and callsites. This is owned by the associated on-disk
661 // hash table, but unused after this point. See also the comment added to
662 // the client which constructs the on-disk hash table for this trait.
663 V.clear();
664 }
665};
666
669
670 bool operator<(const LineLocation &O) const {
671 return std::tie(LineOffset, Column) < std::tie(O.LineOffset, O.Column);
672 }
673
674 bool operator==(const LineLocation &O) const {
675 return LineOffset == O.LineOffset && Column == O.Column;
676 }
677
678 bool operator!=(const LineLocation &O) const {
679 return LineOffset != O.LineOffset || Column != O.Column;
680 }
681
682 uint64_t getHashCode() const { return ((uint64_t)Column << 32) | LineOffset; }
683
686};
687
688// A pair of a call site location and its corresponding callee GUID.
689using CallEdgeTy = std::pair<LineLocation, uint64_t>;
690} // namespace memprof
691
692template <> struct DenseMapInfo<memprof::LineLocation> {
693 static unsigned getHashValue(const memprof::LineLocation &Val) {
695 }
696
698 const memprof::LineLocation &RHS) {
699 return LHS == RHS;
700 }
701};
702
703} // namespace llvm
704#endif // LLVM_PROFILEDATA_MEMPROF_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned uint64_t
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
This file defines the DenseMap class.
#define F(x, y, z)
Definition MD5.cpp:54
#define I(x, y, z)
Definition MD5.cpp:57
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
This file contains library features backported from future STL versions.
This file defines the SmallVector class.
Value * RHS
Value * LHS
Tagged union holding either a T or a Error.
Definition Error.h:485
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
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.
Definition StringRef.h:56
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
Definition StringRef.h:635
An efficient, type-erasing, non-owning reference to a callable.
const IndexedMemProfRecord & data_type
Definition MemProf.h:558
static bool EqualKey(uint64_t A, uint64_t B)
Definition MemProf.h:568
uint64_t ReadKey(const unsigned char *D, offset_type)
Definition MemProf.h:585
data_type ReadData(uint64_t K, const unsigned char *D, offset_type)
Definition MemProf.h:590
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
Definition MemProf.h:575
static uint64_t GetInternalKey(uint64_t K)
Definition MemProf.h:569
hash_value_type ComputeHash(uint64_t K)
Definition MemProf.h:572
static uint64_t GetExternalKey(uint64_t K)
Definition MemProf.h:570
RecordLookupTrait(IndexedVersion V, const MemProfSchema &S)
Definition MemProf.h:565
static hash_value_type ComputeHash(key_type_ref K)
Definition MemProf.h:635
RecordWriterTrait(const MemProfSchema *Schema, IndexedVersion V, llvm::DenseMap< CallStackId, LinearCallStackId > *MemProfCallStackIndexes)
Definition MemProf.h:629
IndexedMemProfRecord data_type
Definition MemProf.h:611
std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
Definition MemProf.h:638
IndexedMemProfRecord & data_type_ref
Definition MemProf.h:612
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
Definition MemProf.h:649
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
Definition MemProf.h:655
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr uint64_t MaximumSupportedVersion
Definition MemProf.h:51
uint32_t LinearCallStackId
Definition MemProf.h:356
LLVM_ABI MemProfSchema getHotColdSchema()
Definition MemProf.cpp:19
llvm::StringRef getMemprofOptionsSymbolName()
Definition MemProf.h:60
llvm::SmallVector< Meta, static_cast< int >(Meta::Size)> MemProfSchema
Definition MemProf.h:74
constexpr uint64_t MinimumSupportedVersion
Definition MemProf.h:50
std::pair< LineLocation, uint64_t > CallEdgeTy
Definition MemProf.h:689
LLVM_ABI MemProfSchema getFullSchema()
Definition MemProf.cpp:11
LLVM_ABI GlobalValue::GUID getGUID(const StringRef FunctionName)
Definition MemProf.cpp:262
LLVM_ABI Expected< MemProfSchema > readMemProfSchema(const unsigned char *&Buffer)
Definition MemProf.cpp:278
uint32_t LinearFrameId
Definition MemProf.h:236
uint64_t CallStackId
Definition MemProf.h:353
llvm::StringRef getMemprofOptionsSymbolDarwinLinkageName()
Definition MemProf.h:56
uint64_t FrameId
Definition MemProf.h:234
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:67
This is an optimization pass for GlobalISel generic memory operations.
constexpr std::underlying_type_t< Enum > to_underlying(Enum E)
Returns underlying integer value of an enum.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
@ Other
Any other memory.
Definition ModRef.h:68
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1933
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
#define N
static unsigned getHashValue(const memprof::LineLocation &Val)
Definition MemProf.h:693
static bool isEqual(const memprof::LineLocation &LHS, const memprof::LineLocation &RHS)
Definition MemProf.h:697
An information struct used to provide DenseMap with the various necessary components for a given valu...
std::vector< Frame > CallStack
Definition MemProf.h:418
PortableMemInfoBlock Info
Definition MemProf.h:420
void printYAML(raw_ostream &OS) const
Definition MemProf.h:424
bool operator!=(const CallSiteInfo &Other) const
Definition MemProf.h:511
CallSiteInfo(std::vector< Frame > Frames)
Definition MemProf.h:502
std::vector< Frame > Frames
Definition MemProf.h:496
bool operator==(const CallSiteInfo &Other) const
Definition MemProf.h:507
SmallVector< GlobalValue::GUID, 1 > CalleeGuids
Definition MemProf.h:499
CallSiteInfo(std::vector< Frame > Frames, SmallVector< GlobalValue::GUID, 1 > CalleeGuids)
Definition MemProf.h:503
Frame & operator=(const Frame &Other)
Definition MemProf.h:279
Frame(const Frame &Other)
Definition MemProf.h:259
static constexpr size_t serializedSize()
Definition MemProf.h:336
void printYAML(raw_ostream &OS) const
Definition MemProf.h:342
GlobalValue::GUID Function
Definition MemProf.h:243
void serialize(raw_ostream &OS) const
Definition MemProf.h:304
bool hasSymbolName() const
Definition MemProf.h:292
std::string getSymbolNameOr(StringRef Alt) const
Definition MemProf.h:299
Frame(Frame &&)=default
Frame & operator=(Frame &&)=default
StringRef getSymbolName() const
Definition MemProf.h:294
bool operator==(const Frame &Other) const
Definition MemProf.h:272
bool operator!=(const Frame &Other) const
Definition MemProf.h:290
static Frame deserialize(const unsigned char *Ptr)
Definition MemProf.h:321
Frame(GlobalValue::GUID Hash, uint32_t Off, uint32_t Col, bool Inline)
Definition MemProf.h:269
uint32_t LineOffset
Definition MemProf.h:248
std::unique_ptr< std::string > SymbolName
Definition MemProf.h:246
IndexedAllocationInfo(CallStackId CSId, const MemInfoBlock &MB, const MemProfSchema &Schema=getFullSchema())
Definition MemProf.h:390
bool operator==(const IndexedAllocationInfo &Other) const
Definition MemProf.h:400
bool operator!=(const IndexedAllocationInfo &Other) const
Definition MemProf.h:409
IndexedAllocationInfo(CallStackId CSId, const PortableMemInfoBlock &MB)
Definition MemProf.h:393
bool operator!=(const IndexedCallSiteInfo &Other) const
Definition MemProf.h:375
IndexedCallSiteInfo(CallStackId CSId, SmallVector< GlobalValue::GUID, 1 > CalleeGuids)
Definition MemProf.h:367
IndexedCallSiteInfo(CallStackId CSId)
Definition MemProf.h:366
SmallVector< GlobalValue::GUID, 1 > CalleeGuids
Definition MemProf.h:363
bool operator==(const IndexedCallSiteInfo &Other) const
Definition MemProf.h:371
llvm::SmallVector< IndexedAllocationInfo > AllocSites
Definition MemProf.h:442
static LLVM_ABI IndexedMemProfRecord deserialize(const MemProfSchema &Schema, const unsigned char *Buffer, IndexedVersion Version)
Definition MemProf.cpp:229
bool operator==(const IndexedMemProfRecord &Other) const
Definition MemProf.h:461
void merge(const IndexedMemProfRecord &Other)
Definition MemProf.h:452
llvm::SmallVector< IndexedCallSiteInfo > CallSites
Definition MemProf.h:448
LineLocation(uint32_t L, uint32_t D)
Definition MemProf.h:668
bool operator!=(const LineLocation &O) const
Definition MemProf.h:678
bool operator==(const LineLocation &O) const
Definition MemProf.h:674
bool operator<(const LineLocation &O) const
Definition MemProf.h:670
uint64_t getHashCode() const
Definition MemProf.h:682
llvm::SmallVector< CallSiteInfo > CallSites
Definition MemProf.h:523
llvm::SmallVector< AllocationInfo > AllocSites
Definition MemProf.h:521
void print(llvm::raw_ostream &OS) const
Definition MemProf.h:528
bool operator!=(const PortableMemInfoBlock &Other) const
Definition MemProf.h:198
void deserialize(const MemProfSchema &IncomingSchema, const unsigned char *Ptr)
Definition MemProf.h:102
uint64_t uint64_t uint32_t uint32_t uint64_t uint32_t uint32_t uint32_t uint32_t uint64_t uint32_t uint32_t AccessHistogramSize
Definition MemProf.h:55
std::bitset< llvm::to_underlying(Meta::Size)> getSchema() const
Definition MemProf.h:161
static size_t serializedSize(const MemProfSchema &Schema)
Definition MemProf.h:202
void printYAML(raw_ostream &OS) const
Definition MemProf.h:145
void serialize(const MemProfSchema &Schema, raw_ostream &OS) const
Definition MemProf.h:126
PortableMemInfoBlock(const MemInfoBlock &Block, const MemProfSchema &IncomingSchema)
Definition MemProf.h:87
uint64_t uint64_t uint32_t uint32_t uint64_t uint32_t uint32_t uint32_t uint32_t uint64_t uint32_t uint32_t uint32_t uint32_t uint64_t uint64_t uint32_t uint32_t uint32_t uint32_t uint32_t uint32_t uint64_t uint32_t uint64_t uint32_t uintptr_t void clear()
Definition MemProf.h:183
bool operator==(const PortableMemInfoBlock &Other) const
Definition MemProf.h:185
uint64_t uint64_t uint32_t uint32_t uint64_t uint32_t uint32_t uint32_t uint32_t uint64_t uint32_t uint32_t uint32_t uint32_t uint64_t uint64_t uint32_t uint32_t uint32_t uint32_t uint32_t uint32_t uint64_t uint32_t uint64_t uint32_t AccessHistogram
Definition MemProf.h:121
Represents the relative location of an instruction.
Definition SampleProf.h:352
Adapter to write values to a stream in a particular byte order.
This class should be specialized by any type that needs to be converted to/from a YAML mapping in the...
Definition YAMLTraits.h:274