|
LLVM
10.0.0
|
Sample-based profile reader. More...
#include "llvm/ProfileData/SampleProfReader.h"
Public Member Functions | |
| SampleProfileReader (std::unique_ptr< MemoryBuffer > B, LLVMContext &C, SampleProfileFormat Format=SPF_None) | |
| virtual | ~SampleProfileReader ()=default |
| virtual std::error_code | readHeader ()=0 |
| Read and validate the file header. More... | |
| std::error_code | read () |
| The interface to read sample profiles from the associated file. More... | |
| virtual std::error_code | readImpl ()=0 |
| The implementaion to read sample profiles from the associated file. More... | |
| void | dumpFunctionProfile (StringRef FName, raw_ostream &OS=dbgs()) |
Print the profile for FName on stream OS. More... | |
| virtual void | collectFuncsFrom (const Module &M) |
| void | dump (raw_ostream &OS=dbgs()) |
Print all the profiles on stream OS. More... | |
| FunctionSamples * | getSamplesFor (const Function &F) |
Return the samples collected for function F. More... | |
| FunctionSamples * | getOrCreateSamplesFor (const Function &F) |
Return the samples collected for function F, create empty FunctionSamples if it doesn't exist. More... | |
| virtual FunctionSamples * | getSamplesFor (StringRef Fname) |
Return the samples collected for function F. More... | |
| StringMap< FunctionSamples > & | getProfiles () |
| Return all the profiles. More... | |
| void | reportError (int64_t LineNumber, Twine Msg) const |
| Report a parse error message. More... | |
| ProfileSummary & | getSummary () const |
| Return the profile summary. More... | |
| MemoryBuffer * | getBuffer () const |
| SampleProfileFormat | getFormat () const |
| Return the profile format. More... | |
| virtual std::unique_ptr< ProfileSymbolList > | getProfileSymbolList () |
| virtual std::vector< StringRef > * | getNameTable () |
| It includes all the names that have samples either in outline instance or inline instance. More... | |
| virtual bool | dumpSectionInfo (raw_ostream &OS=dbgs()) |
Static Public Member Functions | |
| static ErrorOr< std::unique_ptr< SampleProfileReader > > | create (const std::string Filename, LLVMContext &C, const std::string RemapFilename="") |
| Create a sample profile reader appropriate to the file format. More... | |
| static ErrorOr< std::unique_ptr< SampleProfileReader > > | create (std::unique_ptr< MemoryBuffer > &B, LLVMContext &C, const std::string RemapFilename="") |
| Create a sample profile reader from the supplied memory buffer. More... | |
Protected Member Functions | |
| void | computeSummary () |
| Compute summary for this profile. More... | |
Static Protected Member Functions | |
| static std::unique_ptr< ProfileSummary > | takeSummary (SampleProfileReader &Reader) |
| Take ownership of the summary of this reader. More... | |
Protected Attributes | |
| StringMap< FunctionSamples > | Profiles |
| Map every function to its associated profile. More... | |
| LLVMContext & | Ctx |
| LLVM context used to emit diagnostics. More... | |
| std::unique_ptr< MemoryBuffer > | Buffer |
| Memory buffer holding the profile file. More... | |
| std::unique_ptr< ProfileSummary > | Summary |
| Profile summary information. More... | |
| std::unique_ptr< SampleProfileReaderItaniumRemapper > | Remapper |
| SampleProfileFormat | Format = SPF_None |
| The format of sample. More... | |
Sample-based profile reader.
Each profile contains sample counts for all the functions executed. Inside each function, statements are annotated with the collected samples on all the instructions associated with that statement.
For this to produce meaningful data, the program needs to be compiled with some debug information (at minimum, line numbers: -gline-tables-only). Otherwise, it will be impossible to match IR instructions to the line numbers collected by the profiler.
From the profile file, we are interested in collecting the following information:
The reader supports two file formats: text and binary. The text format is useful for debugging and testing, while the binary format is more compact and I/O efficient. They can both be used interchangeably.
Definition at line 321 of file SampleProfReader.h.
|
inline |
Definition at line 323 of file SampleProfReader.h.
|
virtualdefault |
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileReaderCompactBinary, and llvm::sampleprof::SampleProfileReaderExtBinary.
Definition at line 347 of file SampleProfReader.h.
References llvm::dbgs(), and llvm::dump().
|
protected |
Compute summary for this profile.
Definition at line 1370 of file SampleProfReader.cpp.
References llvm::SampleProfileSummaryBuilder::addRecord(), llvm::ProfileSummaryBuilder::DefaultCutoffs, llvm::SampleProfileSummaryBuilder::getSummary(), I, Profiles, and Summary.
Referenced by llvm::sampleprof::SampleProfileReaderGCC::readFunctionProfiles(), and llvm::sampleprof::SampleProfileReaderText::readImpl().
|
static |
Create a sample profile reader appropriate to the file format.
Create a sample profile reader based on the format of the input file.
Create a remapper underlying if RemapFilename is not empty.
| Filename | The file to open. |
| C | The LLVM context to use to emit diagnostics. |
| RemapFilename | The file used for profile remapping. |
Definition at line 1266 of file SampleProfReader.cpp.
References C, and setupMemoryBuffer().
Referenced by llvm::sampleprof::SampleProfileReaderItaniumRemapper::create().
|
static |
Create a sample profile reader from the supplied memory buffer.
Create a sample profile reader based on the format of the input data.
Create a remapper underlying if RemapFilename is not empty.
| B | The memory buffer to create the reader from (assumes ownership). |
| C | The LLVM context to use to emit diagnostics. |
| RemapFilename | The file used for profile remapping. |
Definition at line 1333 of file SampleProfReader.cpp.
References llvm::sampleprof::SampleProfileReaderItaniumRemapper::create(), llvm::LLVMContext::diagnose(), llvm::sampleprof::FunctionSamples::Format, llvm::sampleprof::SampleProfileReaderText::hasFormat(), llvm::sampleprof::SampleProfileReaderRawBinary::hasFormat(), llvm::sampleprof::SampleProfileReaderExtBinary::hasFormat(), llvm::sampleprof::SampleProfileReaderCompactBinary::hasFormat(), llvm::sampleprof::SampleProfileReaderGCC::hasFormat(), and llvm::unrecognized_format.
| void SampleProfileReader::dump | ( | raw_ostream & | OS = dbgs() | ) |
Print all the profiles on stream OS.
Dump all the function profiles found on stream OS.
Definition at line 57 of file SampleProfReader.cpp.
References dumpFunctionProfile(), I, and Profiles.
| void SampleProfileReader::dumpFunctionProfile | ( | StringRef | FName, |
| raw_ostream & | OS = dbgs() |
||
| ) |
Print the profile for FName on stream OS.
Dump the function profile for FName.
| FName | Name of the function to print. |
| OS | Stream to emit the output to. |
Definition at line 51 of file SampleProfReader.cpp.
References Profiles.
Referenced by dump().
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileReaderExtBinaryBase.
Definition at line 420 of file SampleProfReader.h.
|
inline |
Definition at line 408 of file SampleProfReader.h.
|
inline |
Return the profile format.
Definition at line 411 of file SampleProfReader.h.
|
inlinevirtual |
It includes all the names that have samples either in outline instance or inline instance.
Reimplemented in llvm::sampleprof::SampleProfileReaderBinary.
Definition at line 419 of file SampleProfReader.h.
|
inline |
Return the samples collected for function F, create empty FunctionSamples if it doesn't exist.
Definition at line 363 of file SampleProfReader.h.
References llvm::sampleprof::FunctionSamples::getCanonicalFnName(), and llvm::sampleprof::getRepInFormat().
|
inline |
Return all the profiles.
Definition at line 385 of file SampleProfReader.h.
Referenced by llvm::createSampleProfileLoaderPass().
|
inlinevirtual |
Reimplemented in llvm::sampleprof::SampleProfileReaderExtBinary.
Definition at line 413 of file SampleProfReader.h.
|
inline |
Return the samples collected for function F.
Definition at line 353 of file SampleProfReader.h.
References llvm::sampleprof::FunctionSamples::getCanonicalFnName(), and llvm::sampleprof::SampleProfileReaderItaniumRemapper::getSamplesFor().
Referenced by llvm::createSampleProfileLoaderPass().
|
inlinevirtual |
Return the samples collected for function F.
Definition at line 371 of file SampleProfReader.h.
References llvm::X86AS::FS, and llvm::sampleprof::getRepInFormat().
|
inline |
Return the profile summary.
Definition at line 406 of file SampleProfReader.h.
Referenced by llvm::createSampleProfileLoaderPass().
|
inline |
The interface to read sample profiles from the associated file.
Definition at line 333 of file SampleProfReader.h.
References llvm::dbgs(), and llvm::success.
|
pure virtual |
Read and validate the file header.
Implemented in llvm::sampleprof::SampleProfileReaderGCC, llvm::sampleprof::SampleProfileReaderExtBinaryBase, llvm::sampleprof::SampleProfileReaderBinary, and llvm::sampleprof::SampleProfileReaderText.
|
pure virtual |
The implementaion to read sample profiles from the associated file.
Implemented in llvm::sampleprof::SampleProfileReaderGCC, llvm::sampleprof::SampleProfileReaderCompactBinary, llvm::sampleprof::SampleProfileReaderExtBinaryBase, llvm::sampleprof::SampleProfileReaderBinary, and llvm::sampleprof::SampleProfileReaderText.
|
inline |
Report a parse error message.
Definition at line 388 of file SampleProfReader.h.
References B, C, and llvm::sampleprof::SampleProfileReaderItaniumRemapper::create().
Referenced by llvm::sampleprof::SampleProfileReaderText::readImpl(), and llvm::sampleprof::SampleProfileReaderGCC::readNumber().
|
inlinestaticprotected |
Take ownership of the summary of this reader.
Definition at line 441 of file SampleProfReader.h.
References Summary.
|
protected |
Memory buffer holding the profile file.
Definition at line 434 of file SampleProfReader.h.
Referenced by llvm::sampleprof::SampleProfileReaderBinary::readHeader(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readHeader(), llvm::sampleprof::SampleProfileReaderText::readImpl(), llvm::sampleprof::SampleProfileReaderExtBinaryBase::readImpl(), llvm::sampleprof::SampleProfileReaderCompactBinary::readImpl(), and setupMemoryBuffer().
|
protected |
LLVM context used to emit diagnostics.
Definition at line 431 of file SampleProfReader.h.
|
protected |
The format of sample.
Definition at line 451 of file SampleProfReader.h.
|
protected |
Map every function to its associated profile.
The profile of every function executed at runtime is collected in the structure FunctionSamples. This maps function objects to their corresponding profiles.
Definition at line 420 of file SampleProfReader.h.
Referenced by computeSummary(), dump(), dumpFunctionProfile(), llvm::sampleprof::SampleProfileReaderText::readImpl(), and llvm::sampleprof::SampleProfileReaderGCC::readOneFunctionProfile().
|
protected |
Definition at line 448 of file SampleProfReader.h.
|
protected |
Profile summary information.
Definition at line 437 of file SampleProfReader.h.
Referenced by computeSummary(), llvm::sampleprof::SampleProfileReaderBinary::readSummary(), and takeSummary().
1.8.13