Go to the documentation of this file. 1 #ifndef LLVM_PROFILEDATA_MEMPROF_H_
2 #define LLVM_PROFILEDATA_MEMPROF_H_
20 #define MIBEntryDef(NameTag, Name, Type) NameTag,
34 #define MIBEntryDef(NameTag, Name, Type) Name = Block.Name;
48 for (
const Meta Id : Schema) {
50 #define MIBEntryDef(NameTag, Name, Type) \
52 Name = endian::readNext<Type, little, unaligned>(Ptr); \
58 "a newer version of the runtime?");
69 for (
const Meta Id : Schema) {
71 #define MIBEntryDef(NameTag, Name, Type) \
73 LE.write<Type>(Name); \
85 OS <<
" MemInfoBlock:\n";
86 #define MIBEntryDef(NameTag, Name, Type) \
87 OS << " " << #Name << ": " << Name << "\n";
93 #define MIBEntryDef(NameTag, Name, Type) \
94 Type get##Name() const { return Name; }
103 #define MIBEntryDef(NameTag, Name, Type) List.push_back(Meta::Name);
110 #define MIBEntryDef(NameTag, Name, Type) \
111 if (Other.get##Name() != get##Name()) \
124 #define MIBEntryDef(NameTag, Name, Type) Result += sizeof(Type);
131 #define MIBEntryDef(NameTag, Name, Type) Type Name = Type();
159 LineOffset =
Other.LineOffset;
160 Column =
Other.Column;
161 IsInlineFrame =
Other.IsInlineFrame;
165 :
Function(Hash), LineOffset(Off), Column(Col), IsInlineFrame(Inline) {}
171 Other.Column == Column &&
Other.IsInlineFrame == IsInlineFrame;
177 LineOffset =
Other.LineOffset;
178 Column =
Other.Column;
179 IsInlineFrame =
Other.IsInlineFrame;
193 static_assert(std::is_same<GlobalValue::GUID, uint64_t>::value,
194 "Expect GUID to be uint64_t.");
199 LE.write<
bool>(IsInlineFrame);
206 const uint64_t F = endian::readNext<uint64_t, little, unaligned>(Ptr);
207 const uint32_t L = endian::readNext<uint32_t, little, unaligned>(Ptr);
208 const uint32_t C = endian::readNext<uint32_t, little, unaligned>(Ptr);
209 const bool I = endian::readNext<bool, little, unaligned>(Ptr);
223 <<
" Function: " <<
Function <<
"\n"
224 <<
" SymbolName: " <<
SymbolName.value_or(
"<None>") <<
"\n"
225 <<
" LineOffset: " << LineOffset <<
"\n"
226 <<
" Column: " << Column <<
"\n"
227 <<
" Inline: " << IsInlineFrame <<
"\n";
234 auto HashCombine = [](
auto Value,
size_t Seed) {
235 std::hash<decltype(
Value)> Hasher;
239 return Hasher(
Value) + 0x9e3779b97f4a7c15 + (
Seed << 6) + (
Seed >> 2);
243 Result ^= HashCombine(
Function, Result);
244 Result ^= HashCombine(LineOffset, Result);
245 Result ^= HashCombine(Column, Result);
246 Result ^= HashCombine(IsInlineFrame, Result);
247 return static_cast<FrameId>(Result);
267 sizeof(
FrameId) * CallStack.size() +
275 if (
Other.CallStack.size() != CallStack.size())
278 for (
size_t J = 0; J <
Other.CallStack.size(); J++) {
279 if (
Other.CallStack[J] != CallStack[J])
303 CallStack.push_back(IdToFrameCallback(
Id));
310 OS <<
" Callstack:\n";
313 for (
const Frame &
F : CallStack) {
349 Result +=
N.serializedSize();
353 for (
const auto &Frames : CallSites) {
356 Result += Frames.size() *
sizeof(
FrameId);
362 if (
Other.AllocSites.size() != AllocSites.size())
365 if (
Other.CallSites.size() != CallSites.size())
368 for (
size_t I = 0;
I < AllocSites.size();
I++) {
369 if (AllocSites[
I] !=
Other.AllocSites[
I])
373 for (
size_t I = 0;
I < CallSites.size();
I++) {
374 if (CallSites[
I] !=
Other.CallSites[
I])
386 const unsigned char *Buffer);
413 Frames.push_back(IdToFrameCallback(
Id));
415 CallSites.push_back(Frames);
421 if (!AllocSites.empty()) {
422 OS <<
" AllocSites:\n";
427 if (!CallSites.empty()) {
428 OS <<
" CallSites:\n";
430 for (
const Frame &
F : Frames) {
464 static std::pair<offset_type, offset_type>
468 offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(
D);
469 offset_type DataLen = endian::readNext<offset_type, little, unaligned>(
D);
470 return std::make_pair(KeyLen, DataLen);
475 return endian::readNext<external_key_type, little, unaligned>(
D);
512 static std::pair<offset_type, offset_type>
521 return std::make_pair(
N,
M);
532 assert(Schema !=
nullptr &&
"MemProf schema is not initialized!");
551 static std::pair<offset_type, offset_type>
559 return std::make_pair(
N,
M);
591 static std::pair<offset_type, offset_type>
595 offset_type KeyLen = endian::readNext<offset_type, little, unaligned>(
D);
596 offset_type DataLen = endian::readNext<offset_type, little, unaligned>(
D);
597 return std::make_pair(KeyLen, DataLen);
602 return endian::readNext<external_key_type, little, unaligned>(
D);
613 #endif // LLVM_PROFILEDATA_MEMPROF_H_
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Frame(const Frame &Other)
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
PortableMemInfoBlock Info
hash_value_type ComputeHash(internal_key_type K)
bool operator==(const IndexedMemProfRecord &Other) const
llvm::SmallVector< FrameId > CallStack
static constexpr size_t serializedSize()
static std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
llvm::SmallVector< llvm::SmallVector< FrameId > > CallSites
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
static MemProfSchema getSchema()
bool operator!=(const Frame &Other) const
static hash_value_type ComputeHash(key_type_ref K)
llvm::SmallVector< AllocationInfo > AllocSites
const_iterator end(StringRef path)
Get end iterator over path.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Tagged union holding either a T or a Error.
MemProfRecord(const IndexedMemProfRecord &Record, llvm::function_ref< const Frame(const FrameId Id)> IdToFrameCallback)
Adapter to write values to a stream in a particular byte order.
size_t serializedSize() const
void printYAML(raw_ostream &OS) const
bool operator!=(const PortableMemInfoBlock &Other) const
static hash_value_type ComputeHash(key_type_ref K)
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
(vector float) vec_cmpeq(*A, *B) C
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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.
static bool EqualKey(internal_key_type A, internal_key_type B)
Analysis containing CSE Info
data_type ReadData(uint64_t K, const unsigned char *D, offset_type)
void printYAML(raw_ostream &OS) const
Expected< MemProfSchema > readMemProfSchema(const unsigned char *&Buffer)
static std::pair< offset_type, offset_type > ReadKeyDataLength(const unsigned char *&D)
An efficient, type-erasing, non-owning reference to a callable.
bool operator!=(const IndexedAllocationInfo &Other) const
static std::pair< offset_type, offset_type > EmitKeyDataLength(raw_ostream &Out, key_type_ref K, data_type_ref V)
bool operator==(const Frame &Other) const
IndexedAllocationInfo(ArrayRef< FrameId > CS, const MemInfoBlock &MB)
static uint64_t GetExternalKey(uint64_t K)
static ManagedStatic< cl::opt< uint64_t >, CreateSeed > Seed
uint64_t ReadKey(const unsigned char *D, offset_type)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
hash_value_type ComputeHash(uint64_t K)
PortableMemInfoBlock()=default
data_type ReadData(uint64_t K, const unsigned char *D, offset_type)
static uint64_t GetExternalKey(external_key_type K)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
uint64_t ReadKey(const unsigned char *D, offset_type)
void EmitData(raw_ostream &Out, key_type_ref, data_type_ref V, offset_type)
void serialize(raw_ostream &OS) const
RecordLookupTrait(const MemProfSchema &S)
PortableMemInfoBlock Info
AllocationInfo(const IndexedAllocationInfo &IndexedAI, llvm::function_ref< const Frame(const FrameId)> IdToFrameCallback)
PortableMemInfoBlock(const MemInfoBlock &Block)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool operator==(const IndexedAllocationInfo &Other) const
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
static bool EqualKey(uint64_t A, uint64_t B)
void merge(const IndexedMemProfRecord &Other)
GlobalValue::GUID Function
constexpr char SymbolName[]
Key for Kernel::Metadata::mSymbolName.
void print(llvm::raw_ostream &OS) const
Frame & operator=(const Frame &Other)
static constexpr size_t serializedSize()
size_t serializedSize() const
Frame(uint64_t Hash, uint32_t Off, uint32_t Col, bool Inline)
static Frame deserialize(const unsigned char *Ptr)
llvm::SmallVector< llvm::SmallVector< Frame > > CallSites
llvm::SmallVector< Frame > CallStack
bool operator==(const PortableMemInfoBlock &Other) const
llvm::SmallVector< IndexedAllocationInfo > AllocSites
static uint64_t GetInternalKey(internal_key_type K)
void serialize(const MemProfSchema &Schema, raw_ostream &OS)
Reimplement select in terms of SEL *We would really like to support but we need to prove that the add doesn t need to overflow between the two bit chunks *Implement pre post increment support(e.g. PR935) *Implement smarter const ant generation for binops with large immediates. A few ARMv6T2 ops should be pattern matched
void printYAML(raw_ostream &OS) const
void EmitKey(raw_ostream &Out, key_type_ref K, offset_type)
static IndexedMemProfRecord deserialize(const MemProfSchema &Schema, const unsigned char *Buffer)
void deserialize(const MemProfSchema &Schema, const unsigned char *Ptr)
void serialize(const MemProfSchema &Schema, raw_ostream &OS) const
PortableMemInfoBlock(const MemProfSchema &Schema, const unsigned char *Ptr)
LLVM Value Representation.
static uint64_t GetInternalKey(uint64_t K)
Optional< std::vector< StOtherPiece > > Other
reference emplace_back(ArgTypes &&... Args)
llvm::Optional< std::string > SymbolName