LLVM: include/llvm/ProfileData/MemProfReader.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_PROFILEDATA_MEMPROFREADER_H_
14#define LLVM_PROFILEDATA_MEMPROFREADER_H_
15
31
32#include
33
34namespace llvm {
36
37
39public:
40
42
50
51
52
54
57 std::function<const Frame(const FrameId)> Callback = nullptr) {
60
63
64 if (Callback == nullptr)
66
69
71 GuidRecord = {
74 };
75 if (CSIdConv.LastUnmappedId)
79 }
80
81
82
85
86
89
90protected:
91
95 return It->second;
96 }
97
99
101};
102
103
104
106
107
108
110public:
114
115
117
118
119
121
122
124
125
126
127
131 create(std::unique_ptr Buffer, StringRef ProfiledBinary,
132 bool KeepName = false);
133
134
136
139 std::function<const Frame(const FrameId)> Callback) override;
140
141
142 RawMemProfReader(std::unique_ptrllvm::symbolize::SymbolizableModule Sym,
146 : SegmentInfo(Seg.begin(), Seg.end()), CallstackProfileData(Prof),
147 StackMap(SM), KeepSymbolName(KeepName) {
148
149
150
151
152
153 if (Error E = symbolizeAndFilterStackFrames(std::move(Sym)))
155 if (Error E = mapRawProfileToRecords())
157 }
158
159private:
161 : Binary(std::move(Bin)), KeepSymbolName(KeepName) {}
162
163 Error initialize(std::unique_ptr DataBuffer);
164
165 Error readRawProfile(std::unique_ptr DataBuffer);
166
167 Error setupForSymbolization();
168
169
170
171
172 Error symbolizeAndFilterStackFrames(
173 std::unique_ptrllvm::symbolize::SymbolizableModule Symbolizer);
174
175
176
177 Error mapRawProfileToRecords();
178
180
182 readMemInfoBlocks(const char *Ptr);
183
184
186
187
188 uint64_t MemprofRawVersion = MEMPROF_RAW_VERSION;
189
190 uint64_t PreferredTextSegmentAddress = 0;
191
192 uint64_t ProfiledTextSegmentStart = 0;
193
194 uint64_t ProfiledTextSegmentEnd = 0;
195
196
197
199
200
201
203 CallStackMap StackMap;
204
205
207
208
209 bool KeepSymbolName = false;
210
212};
213
215public:
217
218
219
221
222
224
225
226
230 create(std::unique_ptr Buffer);
231
233
235 return std::move(DataAccessProfileData);
236 }
237
238private:
239
240
241 void
242 setDataAccessProfileData(std::unique_ptrmemprof::DataAccessProfData Data) {
243 DataAccessProfileData = std::move(Data);
244 }
245
246 std::unique_ptrmemprof::DataAccessProfData DataAccessProfileData;
247};
248}
249}
250
251#endif
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file defines the DenseMap class.
This file implements a map that provides insertion order iteration.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, const llvm::StringTable &StandardNames, VectorLibrary VecLib)
Initialize the set of available library functions based on the specified target triple.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
A file format agnostic iterator over profiling data.
This class implements a map that also provides access to all stored values in a deterministic order.
typename VectorType::iterator iterator
This interface provides simple read-only access to a block of memory, and provides simple methods for...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
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.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Iterator end()
Definition MemProfReader.h:45
const Frame & idToFrame(const FrameId Id) const
Definition MemProfReader.h:92
virtual ~MemProfReader()=default
IndexedMemProfData takeMemProfData()
Definition MemProfReader.h:53
InstrProfIterator< GuidMemProfRecordPair, MemProfReader > Iterator
Definition MemProfReader.h:44
IndexedMemProfData MemProfData
Definition MemProfReader.h:98
Iterator begin()
Definition MemProfReader.h:46
InstrProfKind getProfileKind() const
Definition MemProfReader.h:41
virtual Error readNextRecord(GuidMemProfRecordPair &GuidRecord, std::function< const Frame(const FrameId)> Callback=nullptr)
Definition MemProfReader.h:56
MemProfReader(IndexedMemProfData &&MemProfData)
Definition MemProfReader.h:87
llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord >::iterator Iter
Definition MemProfReader.h:100
std::pair< GlobalValue::GUID, MemProfRecord > GuidMemProfRecordPair
Definition MemProfReader.h:43
Definition MemProfReader.h:109
void printYAML(raw_ostream &OS)
RawMemProfReader & operator=(const RawMemProfReader &)=delete
RawMemProfReader(const RawMemProfReader &)=delete
static Expected< std::unique_ptr< RawMemProfReader > > create(const Twine &Path, StringRef ProfiledBinary, bool KeepName=false)
static std::vector< std::string > peekBuildIds(MemoryBuffer *DataBuffer)
Error readNextRecord(GuidMemProfRecordPair &GuidRecord, std::function< const Frame(const FrameId)> Callback) override
RawMemProfReader(std::unique_ptr< llvm::symbolize::SymbolizableModule > Sym, llvm::SmallVectorImpl< SegmentEntry > &Seg, llvm::MapVector< uint64_t, MemInfoBlock > &Prof, CallStackMap &SM, bool KeepName=false)
Definition MemProfReader.h:142
static bool hasFormat(const MemoryBuffer &DataBuffer)
YAMLMemProfReader()=default
static LLVM_ABI bool hasFormat(const MemoryBuffer &DataBuffer)
std::unique_ptr< memprof::DataAccessProfData > takeDataAccessProfData()
Definition MemProfReader.h:234
static LLVM_ABI Expected< std::unique_ptr< YAMLMemProfReader > > create(const Twine &Path)
LLVM_ABI void parse(StringRef YAMLData)
This class implements an extremely fast bulk output stream that can only output to a stream.
llvm::DenseMap< uint64_t, llvm::SmallVector< uint64_t > > CallStackMap
Definition MemProfReader.h:105
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
FunctionAddr VTableAddr uintptr_t uintptr_t Data
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
InstrProfKind
An enum describing the attributes of an instrumented profile.
Implement std::hash so that hash_code can be used in STL containers.
LLVM_ABI MemProfRecord toMemProfRecord(llvm::function_ref< std::vector< Frame >(const CallStackId)> Callback) const