14#ifndef LLVM_PROFILEDATA_MEMPROF_H 
   15#define LLVM_PROFILEDATA_MEMPROF_H 
   34template <
typename T> 
struct CustomMappingTraits;
 
   59  return "___memprof_default_options_str";
 
 
   70#define MIBEntryDef(NameTag, Name, Type) NameTag, 
 
   91    for (
const Meta Id : IncomingSchema)
 
   93#define MIBEntryDef(NameTag, Name, Type) Name = Block.Name; 
 
  105                   const unsigned char *
Ptr) {
 
  109    for (
const Meta Id : IncomingSchema) {
 
  111#define MIBEntryDef(NameTag, Name, Type)                                       \ 
  113    Name = endian::readNext<Type, llvm::endianness::little>(Ptr);              \ 
  119                         "a newer version of the runtime?");
 
 
  132    for (
const Meta Id : Schema) {
 
  134#define MIBEntryDef(NameTag, Name, Type)                                       \ 
  136    LE.write<Type>(Name);                                                      \ 
 
  148    OS << 
"      MemInfoBlock:\n";
 
  149#define MIBEntryDef(NameTag, Name, Type)                                       \ 
  150  OS << "        " << #Name << ": " << Name << "\n"; 
  154      OS << 
"        " << 
"AccessHistogramValues" << 
":";
 
 
  168#define MIBEntryDef(NameTag, Name, Type)                                       \ 
  169  Type get##Name() const {                                                     \ 
  170    assert(Schema[llvm::to_underlying(Meta::Name)]);                           \ 
  177#define MIBEntryDef(NameTag, Name, Type)                                       \ 
  178  void set##Name(Type NewVal) {                                                \ 
  179    assert(Schema[llvm::to_underlying(Meta::Name)]);                           \ 
  188    if (
Other.Schema != Schema)
 
  191#define MIBEntryDef(NameTag, Name, Type)                                       \ 
  192  if (Schema[llvm::to_underlying(Meta::Name)] &&                               \ 
  193      Other.get##Name() != get##Name())                                        \ 
 
  207    for (
const Meta Id : Schema) {
 
  209#define MIBEntryDef(NameTag, Name, Type)                                       \ 
  211    Result += sizeof(Type);                                                    \ 
 
  228  std::bitset<llvm::to_underlying(Meta::Size)> Schema;
 
  230#define MIBEntryDef(NameTag, Name, Type) Type Name = Type(); 
  231#include "llvm/ProfileData/MIBEntryDef.inc" 
 
  261                     ? std::make_unique<std::string>(*
Other.SymbolName)
 
 
  281                     ? std::make_unique<std::string>(*
Other.SymbolName)
 
 
  310    static_assert(std::is_same<GlobalValue::GUID, uint64_t>::value,
 
  311                  "Expect GUID to be uint64_t.");
 
 
  343       << 
"        Function: " << 
Function << 
"\n" 
  346       << 
"        Column: " << 
Column << 
"\n" 
 
 
  425    OS << 
"      Callstack:\n";
 
 
 
  474                              *MemProfCallStackIndexes = 
nullptr) 
const;
 
  478                                                   const unsigned char *Buffer,
 
 
  529      OS << 
"    AllocSites:\n";
 
  535      OS << 
"    CallSites:\n";
 
  537        for (
const Frame &
F : CS.Frames) {
 
 
 
  565      : Version(V), Schema(S) {}
 
 
  573  static std::pair<offset_type, offset_type>
 
  581    return std::make_pair(KeyLen, DataLen);
 
 
 
  631      : Schema(Schema), Version(V),
 
  632        MemProfCallStackIndexes(MemProfCallStackIndexes) {}
 
 
  636  std::pair<offset_type, offset_type>
 
  643    offset_type M = V.serializedSize(*Schema, Version);
 
  645    return std::make_pair(
N, M);
 
 
  656    assert(Schema != 
nullptr && 
"MemProf schema is not initialized!");
 
  657    V.serialize(*Schema, Out, Version, MemProfCallStackIndexes);
 
 
 
  680  static std::pair<offset_type, offset_type>
 
  688    return std::make_pair(
N, M);
 
 
 
  720  static std::pair<offset_type, offset_type>
 
  728    return std::make_pair(KeyLen, DataLen);
 
 
 
  756  static std::pair<offset_type, offset_type>
 
  764    return std::make_pair(
N, M);
 
 
 
  801  static std::pair<offset_type, offset_type>
 
  809    return std::make_pair(KeyLen, DataLen);
 
 
  824    for (
size_t I = 0; 
I != NumFrames; ++
I) {
 
 
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
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")
static StringRef getSymbolName(SymbolKind SymKind)
This file defines the DenseMap class.
bool operator==(const MergedFunctionsInfo &LHS, const MergedFunctionsInfo &RHS)
This file contains library features backported from future STL versions.
This file defines the SmallVector class.
Tagged union holding either a T or a Error.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
void reserve(size_type N)
void push_back(const T &Elt)
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.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
An efficient, type-erasing, non-owning reference to a callable.
CallStackId internal_key_type
static uint64_t GetInternalKey(internal_key_type K)
hash_value_type ComputeHash(internal_key_type K)
static bool EqualKey(internal_key_type A, internal_key_type B)
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
const llvm::SmallVector< FrameId > data_type
CallStackId external_key_type
uint64_t ReadKey(const unsigned char *D, offset_type)
data_type ReadData(uint64_t K, const unsigned char *D, offset_type Length)
CallStackId hash_value_type
static uint64_t GetExternalKey(external_key_type K)
llvm::SmallVector< FrameId > & data_type_ref
static hash_value_type ComputeHash(key_type_ref K)
static std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
CallStackId hash_value_type
llvm::SmallVector< FrameId > data_type
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
FrameId external_key_type
data_type ReadData(uint64_t K, const unsigned char *D, offset_type)
static uint64_t GetExternalKey(external_key_type K)
static bool EqualKey(internal_key_type A, internal_key_type B)
FrameId internal_key_type
static uint64_t GetInternalKey(internal_key_type K)
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
hash_value_type ComputeHash(internal_key_type K)
uint64_t ReadKey(const unsigned char *D, offset_type)
static hash_value_type ComputeHash(key_type_ref K)
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
static std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
const IndexedMemProfRecord & data_type
static bool EqualKey(uint64_t A, uint64_t B)
uint64_t ReadKey(const unsigned char *D, offset_type)
data_type ReadData(uint64_t K, const unsigned char *D, offset_type)
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
uint64_t internal_key_type
static uint64_t GetInternalKey(uint64_t K)
hash_value_type ComputeHash(uint64_t K)
static uint64_t GetExternalKey(uint64_t K)
uint64_t external_key_type
RecordLookupTrait(IndexedVersion V, const MemProfSchema &S)
RecordLookupTrait()=delete
static hash_value_type ComputeHash(key_type_ref K)
RecordWriterTrait(const MemProfSchema *Schema, IndexedVersion V, llvm::DenseMap< CallStackId, LinearCallStackId > *MemProfCallStackIndexes)
IndexedMemProfRecord data_type
std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
RecordWriterTrait()=delete
IndexedMemProfRecord & data_type_ref
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
constexpr uint64_t MaximumSupportedVersion
uint32_t LinearCallStackId
LLVM_ABI MemProfSchema getHotColdSchema()
llvm::StringRef getMemprofOptionsSymbolName()
llvm::SmallVector< Meta, static_cast< int >(Meta::Size)> MemProfSchema
constexpr uint64_t MinimumSupportedVersion
std::pair< LineLocation, uint64_t > CallEdgeTy
LLVM_ABI MemProfSchema getFullSchema()
LLVM_ABI GlobalValue::GUID getGUID(const StringRef FunctionName)
LLVM_ABI Expected< MemProfSchema > readMemProfSchema(const unsigned char *&Buffer)
llvm::StringRef getMemprofOptionsSymbolDarwinLinkageName()
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.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr uintptr_t uintptr_t Version
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...
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Implement std::hash so that hash_code can be used in STL containers.
std::vector< Frame > CallStack
PortableMemInfoBlock Info
void printYAML(raw_ostream &OS) const
bool operator!=(const CallSiteInfo &Other) const
CallSiteInfo(std::vector< Frame > Frames)
std::vector< Frame > Frames
bool operator==(const CallSiteInfo &Other) const
SmallVector< GlobalValue::GUID, 1 > CalleeGuids
CallSiteInfo(std::vector< Frame > Frames, SmallVector< GlobalValue::GUID, 1 > CalleeGuids)
Frame & operator=(const Frame &Other)
Frame(const Frame &Other)
static constexpr size_t serializedSize()
void printYAML(raw_ostream &OS) const
GlobalValue::GUID Function
void serialize(raw_ostream &OS) const
bool hasSymbolName() const
std::string getSymbolNameOr(StringRef Alt) const
StringRef getSymbolName() const
bool operator==(const Frame &Other) const
bool operator!=(const Frame &Other) const
static Frame deserialize(const unsigned char *Ptr)
Frame(GlobalValue::GUID Hash, uint32_t Off, uint32_t Col, bool Inline)
std::unique_ptr< std::string > SymbolName
IndexedAllocationInfo(CallStackId CSId, const MemInfoBlock &MB, const MemProfSchema &Schema=getFullSchema())
bool operator==(const IndexedAllocationInfo &Other) const
bool operator!=(const IndexedAllocationInfo &Other) const
PortableMemInfoBlock Info
IndexedAllocationInfo(CallStackId CSId, const PortableMemInfoBlock &MB)
IndexedAllocationInfo()=default
bool operator!=(const IndexedCallSiteInfo &Other) const
IndexedCallSiteInfo(CallStackId CSId, SmallVector< GlobalValue::GUID, 1 > CalleeGuids)
IndexedCallSiteInfo(CallStackId CSId)
IndexedCallSiteInfo()=default
SmallVector< GlobalValue::GUID, 1 > CalleeGuids
bool operator==(const IndexedCallSiteInfo &Other) const
llvm::SmallVector< IndexedAllocationInfo > AllocSites
static LLVM_ABI IndexedMemProfRecord deserialize(const MemProfSchema &Schema, const unsigned char *Buffer, IndexedVersion Version)
bool operator==(const IndexedMemProfRecord &Other) const
void merge(const IndexedMemProfRecord &Other)
llvm::SmallVector< IndexedCallSiteInfo > CallSites
LineLocation(uint32_t L, uint32_t D)
bool operator!=(const LineLocation &O) const
bool operator==(const LineLocation &O) const
bool operator<(const LineLocation &O) const
uint64_t getHashCode() const
llvm::SmallVector< CallSiteInfo > CallSites
llvm::SmallVector< AllocationInfo > AllocSites
void print(llvm::raw_ostream &OS) const
bool operator!=(const PortableMemInfoBlock &Other) const
void deserialize(const MemProfSchema &IncomingSchema, const unsigned char *Ptr)
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
PortableMemInfoBlock()=default
std::bitset< llvm::to_underlying(Meta::Size)> getSchema() const
static size_t serializedSize(const MemProfSchema &Schema)
void printYAML(raw_ostream &OS) const
void serialize(const MemProfSchema &Schema, raw_ostream &OS) const
PortableMemInfoBlock(const MemInfoBlock &Block, const MemProfSchema &IncomingSchema)
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()
bool operator==(const PortableMemInfoBlock &Other) const
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
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...