LLVM 20.0.0git
PerfSharedStructs.h
Go to the documentation of this file.
1//===--- PerfSharedStructs.h --- RPC Structs for perf support ---*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Structs and serialization to share perf-related information
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_PERFSHAREDSTRUCTS_H
14#define LLVM_EXECUTIONENGINE_ORC_SHARED_PERFSHAREDSTRUCTS_H
15
17
18namespace llvm {
19
20namespace orc {
21
22// The following are POD struct definitions from the perf jit specification
23
25 JIT_CODE_LOAD = 0,
26 JIT_CODE_MOVE = 1, // not emitted, code isn't moved
28 JIT_CODE_CLOSE = 3, // not emitted, unnecessary
29 JIT_CODE_UNWINDING_INFO = 4, // not emitted
30
32};
33
35 PerfJITRecordType Id; // record type identifier, uint32_t
37};
40
47 std::string Name;
48};
49
52 uint32_t Lineno; // source line number starting at 1
53 uint32_t Discrim; // column discriminator, 0 is default
54 std::string Name;
55};
56
59
61 std::vector<PerfJITDebugEntry> Entries;
62};
63
66
70 // Union, one will always be 0/"", the other has data
72 std::string EHFrameHdr;
73
75 // size is UnwindDataSize - EHFrameHdrSize
76};
77
78// Batch vehicle for minimizing RPC calls for perf jit records
80 std::vector<PerfJITDebugInfoRecord> DebugInfoRecords;
81 std::vector<PerfJITCodeLoadRecord> CodeLoadRecords;
82 // only valid if record size > 0
84};
85
86// SPS traits for Records
87
88namespace shared {
89
91
92template <>
94public:
95 static size_t size(const PerfJITRecordPrefix &Val) {
96 return SPSPerfJITRecordPrefix::AsArgList::size(
97 static_cast<uint32_t>(Val.Id), Val.TotalSize);
98 }
100 uint32_t Id;
101 if (!SPSPerfJITRecordPrefix::AsArgList::deserialize(IB, Id, Val.TotalSize))
102 return false;
103 Val.Id = static_cast<PerfJITRecordType>(Id);
104 return true;
105 }
106 static bool serialize(SPSOutputBuffer &OB, const PerfJITRecordPrefix &Val) {
107 return SPSPerfJITRecordPrefix::AsArgList::serialize(
108 OB, static_cast<uint32_t>(Val.Id), Val.TotalSize);
109 }
110};
111
115
116template <>
118public:
119 static size_t size(const PerfJITCodeLoadRecord &Val) {
120 return SPSPerfJITCodeLoadRecord::AsArgList::size(
121 Val.Prefix, Val.Pid, Val.Tid, Val.Vma, Val.CodeAddr, Val.CodeSize,
122 Val.CodeIndex, Val.Name);
123 }
124
126 return SPSPerfJITCodeLoadRecord::AsArgList::deserialize(
127 IB, Val.Prefix, Val.Pid, Val.Tid, Val.Vma, Val.CodeAddr, Val.CodeSize,
128 Val.CodeIndex, Val.Name);
129 }
130
131 static bool serialize(SPSOutputBuffer &OB, const PerfJITCodeLoadRecord &Val) {
132 return SPSPerfJITCodeLoadRecord::AsArgList::serialize(
133 OB, Val.Prefix, Val.Pid, Val.Tid, Val.Vma, Val.CodeAddr, Val.CodeSize,
134 Val.CodeIndex, Val.Name);
135 }
136};
137
139
140template <>
142public:
143 static size_t size(const PerfJITDebugEntry &Val) {
144 return SPSPerfJITDebugEntry::AsArgList::size(Val.Addr, Val.Lineno,
145 Val.Discrim, Val.Name);
146 }
147
149 return SPSPerfJITDebugEntry::AsArgList::deserialize(
150 IB, Val.Addr, Val.Lineno, Val.Discrim, Val.Name);
151 }
152
153 static bool serialize(SPSOutputBuffer &OB, const PerfJITDebugEntry &Val) {
154 return SPSPerfJITDebugEntry::AsArgList::serialize(OB, Val.Addr, Val.Lineno,
155 Val.Discrim, Val.Name);
156 }
157};
158
161
162template <>
165public:
166 static size_t size(const PerfJITDebugInfoRecord &Val) {
167 return SPSPerfJITDebugInfoRecord::AsArgList::size(Val.Prefix, Val.CodeAddr,
168 Val.Entries);
169 }
171 return SPSPerfJITDebugInfoRecord::AsArgList::deserialize(
172 IB, Val.Prefix, Val.CodeAddr, Val.Entries);
173 }
174 static bool serialize(SPSOutputBuffer &OB,
175 const PerfJITDebugInfoRecord &Val) {
176 return SPSPerfJITDebugInfoRecord::AsArgList::serialize(
177 OB, Val.Prefix, Val.CodeAddr, Val.Entries);
178 }
179};
180
184template <>
187public:
188 static size_t size(const PerfJITCodeUnwindingInfoRecord &Val) {
189 return SPSPerfJITCodeUnwindingInfoRecord::AsArgList::size(
192 }
195 return SPSPerfJITCodeUnwindingInfoRecord::AsArgList::deserialize(
196 IB, Val.Prefix, Val.UnwindDataSize, Val.EHFrameHdrSize, Val.MappedSize,
198 }
199 static bool serialize(SPSOutputBuffer &OB,
201 return SPSPerfJITCodeUnwindingInfoRecord::AsArgList::serialize(
202 OB, Val.Prefix, Val.UnwindDataSize, Val.EHFrameHdrSize, Val.MappedSize,
204 }
205};
206
210template <>
212public:
213 static size_t size(const PerfJITRecordBatch &Val) {
214 return SPSPerfJITRecordBatch::AsArgList::size(
216 }
218 return SPSPerfJITRecordBatch::AsArgList::deserialize(
220 }
221 static bool serialize(SPSOutputBuffer &OB, const PerfJITRecordBatch &Val) {
222 return SPSPerfJITRecordBatch::AsArgList::serialize(
224 }
225};
226
227} // namespace shared
228
229} // namespace orc
230
231} // namespace llvm
232
233#endif
Input char buffer with underflow check.
Output char buffer with overflow check.
static bool serialize(SPSOutputBuffer &OB, const PerfJITCodeLoadRecord &Val)
static bool serialize(SPSOutputBuffer &OB, const PerfJITCodeUnwindingInfoRecord &Val)
static bool serialize(SPSOutputBuffer &OB, const PerfJITDebugEntry &Val)
static bool serialize(SPSOutputBuffer &OB, const PerfJITDebugInfoRecord &Val)
static bool serialize(SPSOutputBuffer &OB, const PerfJITRecordBatch &Val)
static bool serialize(SPSOutputBuffer &OB, const PerfJITRecordPrefix &Val)
Specialize to describe how to serialize/deserialize to/from the given concrete type.
SPSSequence< char > SPSString
SPS tag type for strings, which are equivalent to sequences of chars.
SPSTuple< uint32_t, uint32_t > SPSPerfJITRecordPrefix
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::vector< PerfJITDebugEntry > Entries
std::vector< PerfJITDebugInfoRecord > DebugInfoRecords
PerfJITCodeUnwindingInfoRecord UnwindingRecord
std::vector< PerfJITCodeLoadRecord > CodeLoadRecords