1#ifndef LLVM_PROFILEDATA_MEMPROFYAML_H_
2#define LLVM_PROFILEDATA_MEMPROFYAML_H_
28 std::vector<memprof::DataAccessProfRecord>
Records;
46template <>
struct ScalarTraits<memprof::GUIDHex64> {
54 if (
all_of(Scalar, [](
char C) {
return std::isdigit(
C); }))
55 return "use a hexadecimal GUID or a function instead";
58 if (Scalar.starts_with_insensitive(
"0x")) {
60 if (Scalar.getAsInteger(0, Num))
61 return "invalid hex64 number";
65 Val = memprof::getGUID(Scalar);
78 class FrameWithHex64 {
83 IsInlineFrame(
F.IsInlineFrame) {}
89 static_assert(std::is_same_v<
decltype(
Function.value),
90 decltype(memprof::Frame::Function)>);
91 decltype(memprof::Frame::LineOffset) LineOffset = 0;
92 decltype(memprof::Frame::Column) Column = 0;
93 decltype(memprof::Frame::IsInlineFrame) IsInlineFrame =
false;
97 MappingNormalization<FrameWithHex64, memprof::Frame> Keys(Io,
F);
99 Io.mapRequired(
"Function", Keys->Function);
100 Io.mapRequired(
"LineOffset", Keys->LineOffset);
101 Io.mapRequired(
"Column", Keys->Column);
102 Io.mapRequired(
"IsInlineFrame", Keys->IsInlineFrame);
107 const auto &[
Function, SymbolName, LineOffset, Column, IsInlineFrame] =
F;
110 static_assert(std::is_same_v<
remove_cvref_t<
decltype(SymbolName)>,
111 std::unique_ptr<std::string>>);
129 static const bool flow =
true;
141#define MIBEntryDef(NameTag, Name, Type) \
142 if (KeyStr == #Name) { \
144 Io.mapRequired(KeyStr.str().c_str(), Value); \
145 MIB.Name = static_cast<Type>(Value); \
146 MIB.Schema.set(llvm::to_underlying(memprof::Meta::Name)); \
151 Io.setError(
"Key is not a valid validation event");
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); \
168 Io.mapRequired(
"Callstack", AI.
CallStack);
169 Io.mapRequired(
"MemInfoBlock", AI.
Info);
178 class CallSiteInfoWithHex64Guids {
182 : Frames(CS.Frames) {
186 CalleeGuids.push_back(memprof::GUIDHex64(
Guid));
194 for (memprof::GUIDHex64 HexGuid : CalleeGuids)
201 decltype(memprof::CallSiteInfo::Frames) Frames;
209 MappingNormalization<CallSiteInfoWithHex64Guids, memprof::CallSiteInfo>
211 Io.mapRequired(
"Frames", Keys->Frames);
213 Io.mapOptional(
"CalleeGuids", Keys->CalleeGuids);
219 Io.mapRequired(
"GUID", Pair.
GUID);
227 Io.mapOptional(
"FileName", Loc.
FileName);
228 Io.mapOptional(
"Line", Loc.
Line);
234 if (Io.outputting()) {
235 if (std::holds_alternative<std::string>(Rec.
SymHandle)) {
236 Io.mapOptional(
"Symbol", std::get<std::string>(Rec.
SymHandle));
238 Io.mapOptional(
"Hash", std::get<uint64_t>(Rec.
SymHandle));
243 Io.mapOptional(
"Symbol", SymName);
244 Io.mapOptional(
"Hash", Hash);
245 if (!SymName.empty()) {
252 Io.mapOptional(
"Locations", Rec.
Locations);
258 Io.mapOptional(
"SampledRecords",
Data.Records);
259 Io.mapOptional(
"KnownColdSymbols",
Data.KnownColdSymbols);
260 Io.mapOptional(
"KnownColdStrHashes",
Data.KnownColdStrHashes);
266 if (!Io.outputting() || !
Data.HeapProfileRecords.empty())
267 Io.mapOptional(
"HeapProfileRecords",
Data.HeapProfileRecords);
270 if (!Io.outputting() || !
Data.YamlifiedDataAccessProfiles.isEmpty())
271 Io.mapOptional(
"DataAccessProfiles",
Data.YamlifiedDataAccessProfiles);
275template <>
struct SequenceTraits<
SmallVector<memprof::GUIDHex64>> {
279 static memprof::GUIDHex64 &
285 static const bool flow =
true;
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file defines the SmallVector class.
#define LLVM_YAML_IS_SEQUENCE_VECTOR(type)
#define LLVM_YAML_STRONG_TYPEDEF(_base, _type)
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.
CallSiteInfoWithHex64Guids(IO &)
memprof::CallSiteInfo denormalize(IO &)
SmallVector< memprof::GUIDHex64 > CalleeGuids
CallSiteInfoWithHex64Guids(IO &, const memprof::CallSiteInfo &CS)
FrameWithHex64(IO &, const memprof::Frame &F)
memprof::Frame denormalize(IO &)
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.
YamlDataAccessProfData YamlifiedDataAccessProfiles
std::vector< GUIDMemProfRecordPair > HeapProfileRecords
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
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.
uint32_t Line
The line number in the source code.
std::string FileName
The filename where the data is located.
std::vector< memprof::DataAccessProfRecord > Records
std::vector< uint64_t > KnownColdStrHashes
std::vector< std::string > KnownColdSymbols
Serializable representation of CallSiteInfo.
static void inputOne(IO &Io, StringRef KeyStr, memprof::PortableMemInfoBlock &MIB)
static void output(IO &Io, memprof::PortableMemInfoBlock &MIB)
static void mapping(IO &Io, memprof::AllMemProfData &Data)
static void mapping(IO &Io, memprof::AllocationInfo &AI)
static void mapping(IO &Io, memprof::CallSiteInfo &CS)
static void mapping(IO &Io, memprof::DataAccessProfRecord &Rec)
static void mapping(IO &Io, memprof::Frame &F)
static void mapping(IO &Io, memprof::GUIDMemProfRecordPair &Pair)
static void mapping(IO &Io, memprof::SourceLocation &Loc)
static void mapping(IO &Io, memprof::YamlDataAccessProfData &Data)
static QuotingType mustQuote(StringRef)
static StringRef input(StringRef Scalar, void *, memprof::GUIDHex64 &Val)
static void output(const memprof::GUIDHex64 &Val, void *, raw_ostream &Out)
static size_t size(IO &io, SmallVector< memprof::GUIDHex64 > &Seq)
static memprof::GUIDHex64 & element(IO &io, SmallVector< memprof::GUIDHex64 > &Seq, size_t Index)