13#ifndef LLVM_PROFILEDATA_MEMPROFREADER_H_
14#define LLVM_PROFILEDATA_MEMPROFREADER_H_
68 std::function<
const Frame(
const FrameId)> Callback =
nullptr) {
75 if (Callback ==
nullptr)
87 if (CSIdConv.LastUnmappedId)
117 return It->getSecond();
159 bool KeepName =
false);
166 std::function<
const Frame(
const FrameId)> Callback)
override;
173 : SegmentInfo(Seg.
begin(), Seg.
end()), CallstackProfileData(Prof),
174 StackMap(SM), KeepSymbolName(KeepName) {
180 if (
Error E = symbolizeAndFilterStackFrames(std::move(
Sym)))
182 if (
Error E = mapRawProfileToRecords())
188 : Binary(
std::
move(
Bin)), KeepSymbolName(KeepName) {}
190 Error initialize(std::unique_ptr<MemoryBuffer> DataBuffer);
192 Error readRawProfile(std::unique_ptr<MemoryBuffer> DataBuffer);
194 Error setupForSymbolization();
199 Error symbolizeAndFilterStackFrames(
200 std::unique_ptr<llvm::symbolize::SymbolizableModule> Symbolizer);
204 Error mapRawProfileToRecords();
209 readMemInfoBlocks(
const char *
Ptr);
215 uint64_t MemprofRawVersion = MEMPROF_RAW_VERSION;
217 uint64_t PreferredTextSegmentAddress = 0;
219 uint64_t ProfiledTextSegmentStart = 0;
221 uint64_t ProfiledTextSegmentEnd = 0;
236 bool KeepSymbolName =
false;
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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...
const Frame & idToFrame(const FrameId Id) const
virtual ~MemProfReader()=default
InstrProfIterator< GuidMemProfRecordPair, MemProfReader > Iterator
InstrProfKind getProfileKind() const
const llvm::DenseMap< CallStackId, llvm::SmallVector< FrameId > > & getCallStacks() const
const llvm::DenseMap< FrameId, Frame > & getFrameMapping() const
virtual Error readNextRecord(GuidMemProfRecordPair &GuidRecord, std::function< const Frame(const FrameId)> Callback=nullptr)
MemProfReader(llvm::DenseMap< FrameId, Frame > FrameIdMap, llvm::DenseMap< CallStackId, llvm::SmallVector< FrameId > > CSIdMap, llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > ProfData)
llvm::DenseMap< FrameId, Frame > IdToFrame
llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord >::iterator Iter
const llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > & getProfileData() const
llvm::MapVector< GlobalValue::GUID, IndexedMemProfRecord > FunctionProfileData
std::pair< GlobalValue::GUID, MemProfRecord > GuidMemProfRecordPair
llvm::DenseMap< CallStackId, llvm::SmallVector< FrameId > > CSIdToCallStack
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)
static bool hasFormat(const MemoryBuffer &DataBuffer)
virtual ~RawMemProfReader() override
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
This is an optimization pass for GlobalISel generic memory operations.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
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.
MemProfRecord toMemProfRecord(llvm::function_ref< std::vector< Frame >(const CallStackId)> Callback) const