52 for (
const auto &Frames :
Record.CallSites) {
55 Result += Frames.size() *
sizeof(
FrameId);
86 using namespace support;
93 for (
const FrameId &Id :
N.CallStack)
95 N.Info.serialize(Schema,
OS);
100 for (
const auto &Frames :
Record.CallSites) {
102 for (
const FrameId &Id : Frames)
109 using namespace support;
116 N.Info.serialize(Schema,
OS);
121 for (
const auto &CSId :
Record.CallSiteIds)
140 const unsigned char *
Ptr) {
141 using namespace support;
147 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
151 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
152 for (
uint64_t J = 0; J < NumFrames; J++) {
154 endian::readNext<FrameId, llvm::endianness::little>(
Ptr);
155 Node.CallStack.push_back(Id);
158 Node.Info.deserialize(Schema,
Ptr);
165 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
166 for (
uint64_t J = 0; J < NumCtxs; J++) {
168 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
171 for (
uint64_t K = 0; K < NumFrames; K++) {
173 endian::readNext<FrameId, llvm::endianness::little>(
Ptr);
176 Record.CallSites.push_back(Frames);
184 const unsigned char *
Ptr) {
185 using namespace support;
191 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
194 Node.CSId = endian::readNext<CallStackId, llvm::endianness::little>(
Ptr);
195 Node.Info.deserialize(Schema,
Ptr);
202 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
203 for (
uint64_t J = 0; J < NumCtxs; J++) {
205 endian::readNext<CallStackId, llvm::endianness::little>(
Ptr);
206 Record.CallSiteIds.push_back(CSId);
214 const unsigned char *
Ptr,
233 AI.
Info = IndexedAI.Info;
235 Record.AllocSites.push_back(AI);
239 Record.CallSites.push_back(Callback(CSId));
261 using namespace support;
263 const unsigned char *
Ptr = Buffer;
265 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
268 "memprof schema invalid");
272 for (
size_t I = 0;
I < NumSchemaIds;
I++) {
274 endian::readNext<uint64_t, llvm::endianness::little>(
Ptr);
277 "memprof schema invalid");
279 Result.push_back(
static_cast<Meta>(
Tag));
293 std::memcpy(&CSId, Hash.data(),
sizeof(Hash));
298 for (
const auto &AS :
Record.AllocSites) {
306 &FunctionProfileData) {
307 for (
const auto &[GUID,
Record] : FunctionProfileData) {
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Tagged union holding either a T or a Error.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
HashResultTy< HasherT_ > final()
Forward to HasherT::final() if available.
Interface to help hash various types through a hasher type.
std::enable_if_t< hashbuilder_detail::IsHashableData< T >::value, HashBuilder & > add(T Value)
Implement hashing for hashable data types, e.g. integral or enum values.
This class implements a map that also provides access to all stored values in a deterministic order.
void reserve(size_type N)
void push_back(const T &Elt)
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.
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.
void verifyIndexedMemProfRecord(const IndexedMemProfRecord &Record)
static size_t serializedSizeV0(const IndexedAllocationInfo &IAI)
CallStackId hashCallStack(ArrayRef< FrameId > CS)
static void serializeV0(const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS)
static IndexedMemProfRecord deserializeV0(const MemProfSchema &Schema, const unsigned char *Ptr)
Expected< MemProfSchema > readMemProfSchema(const unsigned char *&Buffer)
void verifyFunctionProfileData(const llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > &FunctionProfileData)
static void serializeV2(const IndexedMemProfRecord &Record, const MemProfSchema &Schema, raw_ostream &OS)
static size_t serializedSizeV2(const IndexedAllocationInfo &IAI)
static IndexedMemProfRecord deserializeV2(const MemProfSchema &Schema, const unsigned char *Ptr)
This is an optimization pass for GlobalISel generic memory operations.
std::array< uint8_t, NumBytes > BLAKE3Result
The constant LLVM_BLAKE3_OUT_LEN provides the default output length, 32 bytes, which is recommended f...
PortableMemInfoBlock Info
llvm::SmallVector< Frame > CallStack
llvm::SmallVector< FrameId > CallStack
size_t serializedSize(IndexedVersion Version) const
llvm::SmallVector< CallStackId > CallSiteIds
llvm::SmallVector< IndexedAllocationInfo > AllocSites
static IndexedMemProfRecord deserialize(const MemProfSchema &Schema, const unsigned char *Buffer, IndexedVersion Version)
MemProfRecord toMemProfRecord(std::function< const llvm::SmallVector< Frame >(const CallStackId)> Callback) const
size_t serializedSize(IndexedVersion Version) const
void serialize(const MemProfSchema &Schema, raw_ostream &OS, IndexedVersion Version)
static GlobalValue::GUID getGUID(const StringRef FunctionName)
static constexpr size_t serializedSize()
Adapter to write values to a stream in a particular byte order.