LLVM: include/llvm/ProfileData/MemProfYAML.h Source File (original) (raw)
1#ifndef LLVM_PROFILEDATA_MEMPROFYAML_H_
2#define LLVM_PROFILEDATA_MEMPROFYAML_H_
3
9
10namespace llvm {
12
13
15
16
17
18
23
24
25
26
28 std::vectormemprof::DataAccessProfRecord Records;
31
36};
37
38
43}
44
45namespace yaml {
53
54 if (all_of(Scalar, [](char C) { return std::isdigit(C); }))
55 return "use a hexadecimal GUID or a function instead";
56
58 if (Scalar.starts_with_insensitive("0x")) {
59
60 if (Scalar.getAsInteger(0, Num))
61 return "invalid hex64 number";
62 Val = Num;
63 } else {
64
66 }
68 }
70};
71
73
74
75
76
77
79 public:
87
89 static_assert(std::is_same_v<decltype(Function.value),
94 };
95
98
99 Io.mapRequired("Function", Keys->Function);
100 Io.mapRequired("LineOffset", Keys->LineOffset);
102 Io.mapRequired("IsInlineFrame", Keys->IsInlineFrame);
103
104
105
106
107 const auto &[Function, SymbolName, LineOffset, Column, IsInlineFrame] = F;
108 static_assert(
110 static_assert(std::is_same_v<remove_cvref_t<decltype(SymbolName)>,
111 std::unique_ptrstd::string>);
112 static_assert(
115 static_assert(
116 std::is_same_v<remove_cvref_t<decltype(IsInlineFrame)>, bool>);
117
118
119
121 (void)SymbolName;
122 (void)LineOffset;
123 (void)Column;
124 (void)IsInlineFrame;
125 }
126
127
128
129 static const bool flow = true;
130};
131
135
136
137
138
139
140
141#define MIBEntryDef(NameTag, Name, Type) \
142 if (KeyStr == #Name) { \
143 uint64_t Value; \
144 Io.mapRequired(KeyStr, Value); \
145 MIB.Name = static_cast(Value); \
146 MIB.Schema.set(llvm::to_underlying(memprof::Meta::Name)); \
147 return; \
148 }
150#undef MIBEntryDef
151 Io.setError("Key is not a valid validation event");
152 }
153
156#define MIBEntryDef(NameTag, Name, Type) \
157 if (Schema.test(llvm::to_underlying(memprof::Meta::Name))) { \
158 uint64_t Value = MIB.Name; \
159 Io.mapRequired(#Name, Value); \
160 }
162#undef MIBEntryDef
163 }
164};
165
172
173
174
175
177
179 public:
188
192
194 for (memprof::GUIDHex64 HexGuid : CalleeGuids)
196 return CS;
197 }
198
199
200
202
204 };
205
207
208
210 Keys(Io, CS);
212
213 Io.mapOptional("CalleeGuids", Keys->CalleeGuids);
214 }
215};
216
224
231
235 if (std::holds_alternativestd::string(Rec.SymHandle)) {
237 } else {
239 }
240 } else {
241 std::string SymName;
245 if (!SymName.empty()) {
247 } else {
249 }
250 }
253 }
254};
255
263
266 if (!Io.outputting() || .HeapProfileRecords.empty())
267 Io.mapOptional("HeapProfileRecords", Data.HeapProfileRecords);
268
269
270 if (!Io.outputting() || .YamlifiedDataAccessProfiles.isEmpty())
271 Io.mapOptional("DataAccessProfiles", Data.YamlifiedDataAccessProfiles);
272 }
273};
274
277 return Seq.size();
278 }
279 static memprof::GUIDHex64 &
281 if (Index >= Seq.size())
282 Seq.resize(Index + 1);
283 return Seq[Index];
284 }
285 static const bool flow = true;
286};
287
288}
289}
290
299
300#endif
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
This file defines the SmallVector class.
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
Utility for declaring that a std::vector of a particular type should be considered a YAML sequence.
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
YAML I/O does conversion based on types. But often native data types are just a typedef of built in i...
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.
StringRef - Represent a constant reference to a string, i.e.
This class implements an extremely fast bulk output stream that can only output to a stream.
virtual bool outputting() const =0
void mapOptional(StringRef Key, T &Val)
virtual void setError(const Twine &)=0
void mapRequired(StringRef Key, T &Val)
CallSiteInfoWithHex64Guids(IO &)
Definition MemProfYAML.h:180
memprof::CallSiteInfo denormalize(IO &)
Definition MemProfYAML.h:189
SmallVector< memprof::GUIDHex64 > CalleeGuids
Definition MemProfYAML.h:203
decltype(memprof::CallSiteInfo::Frames) Frames
Definition MemProfYAML.h:201
CallSiteInfoWithHex64Guids(IO &, const memprof::CallSiteInfo &CS)
Definition MemProfYAML.h:181
decltype(memprof::Frame::LineOffset) LineOffset
Definition MemProfYAML.h:91
decltype(memprof::Frame::IsInlineFrame) IsInlineFrame
Definition MemProfYAML.h:93
memprof::GUIDHex64 Function
Definition MemProfYAML.h:88
FrameWithHex64(IO &)
Definition MemProfYAML.h:80
decltype(memprof::Frame::Column) Column
Definition MemProfYAML.h:92
FrameWithHex64(IO &, const memprof::Frame &F)
Definition MemProfYAML.h:81
memprof::Frame denormalize(IO &)
Definition MemProfYAML.h:84
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI GlobalValue::GUID getGUID(const StringRef FunctionName)
QuotingType
Describe which type of quotes should be used when quoting is necessary.
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
Definition MemProfYAML.h:39
YamlDataAccessProfData YamlifiedDataAccessProfiles
Definition MemProfYAML.h:41
std::vector< GUIDMemProfRecordPair > HeapProfileRecords
Definition MemProfYAML.h:40
std::vector< Frame > CallStack
PortableMemInfoBlock Info
std::vector< Frame > Frames
SmallVector< GlobalValue::GUID, 1 > CalleeGuids
The data access profiles for a symbol.
SmallVector< SourceLocation > Locations
GlobalValue::GUID Function
Definition MemProfYAML.h:19
MemProfRecord Record
Definition MemProfYAML.h:21
GUIDHex64 GUID
Definition MemProfYAML.h:20
llvm::SmallVector< CallSiteInfo > CallSites
llvm::SmallVector< AllocationInfo > AllocSites
std::bitset< llvm::to_underlying(Meta::Size)> getSchema() const
The location of data in the source code. Used by profile lookup API.
Definition MemProfYAML.h:27
std::vector< memprof::DataAccessProfRecord > Records
Definition MemProfYAML.h:28
std::vector< uint64_t > KnownColdStrHashes
Definition MemProfYAML.h:29
std::vector< std::string > KnownColdSymbols
Definition MemProfYAML.h:30
bool isEmpty() const
Definition MemProfYAML.h:32
Serializable representation of CallSiteInfo.
static void inputOne(IO &Io, StringRef KeyStr, memprof::PortableMemInfoBlock &MIB)
Definition MemProfYAML.h:133
static void output(IO &Io, memprof::PortableMemInfoBlock &MIB)
Definition MemProfYAML.h:154
This class should be specialized by any type that needs to be converted to/from a YAML mapping in the...
static void mapping(IO &Io, memprof::AllMemProfData &Data)
Definition MemProfYAML.h:265
static void mapping(IO &Io, memprof::AllocationInfo &AI)
Definition MemProfYAML.h:167
static void mapping(IO &Io, memprof::CallSiteInfo &CS)
Definition MemProfYAML.h:206
static void mapping(IO &Io, memprof::DataAccessProfRecord &Rec)
Definition MemProfYAML.h:233
static const bool flow
Definition MemProfYAML.h:129
static void mapping(IO &Io, memprof::Frame &F)
Definition MemProfYAML.h:96
static void mapping(IO &Io, memprof::GUIDMemProfRecordPair &Pair)
Definition MemProfYAML.h:218
static void mapping(IO &Io, memprof::SourceLocation &Loc)
Definition MemProfYAML.h:226
static void mapping(IO &Io, memprof::YamlDataAccessProfData &Data)
Definition MemProfYAML.h:257
This class should be specialized by any type that needs to be converted to/from a YAML mapping.
static QuotingType mustQuote(StringRef)
Definition MemProfYAML.h:69
static StringRef input(StringRef Scalar, void *, memprof::GUIDHex64 &Val)
Definition MemProfYAML.h:52
static void output(const memprof::GUIDHex64 &Val, void *, raw_ostream &Out)
Definition MemProfYAML.h:47
This class should be specialized by type that requires custom conversion to/from a yaml scalar.
static const bool flow
Definition MemProfYAML.h:285
static size_t size(IO &io, SmallVector< memprof::GUIDHex64 > &Seq)
Definition MemProfYAML.h:276
static memprof::GUIDHex64 & element(IO &io, SmallVector< memprof::GUIDHex64 > &Seq, size_t Index)
Definition MemProfYAML.h:280
This class should be specialized by any type that needs to be converted to/from a YAML sequence.