|
LLVM
3.7.0
|
Sample-based profile reader. More...
#include <SampleProfReader.h>
Public Member Functions | |
| SampleProfileReader (std::unique_ptr< MemoryBuffer > B, LLVMContext &C) | |
| virtual | ~SampleProfileReader () |
| virtual std::error_code | readHeader ()=0 |
| Read and validate the file header. More... | |
| virtual std::error_code | read ()=0 |
| 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... | |
| 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... | |
| StringMap< FunctionSamples > & | getProfiles () |
| Return all the profiles. More... | |
| void | reportParseError (int64_t LineNumber, Twine Msg) const |
| Report a parse error message. More... | |
Static Public Member Functions | |
| static ErrorOr < std::unique_ptr < SampleProfileReader > > | create (StringRef Filename, LLVMContext &C) |
| Create a sample profile reader appropriate to the file format. 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... | |
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. They can both be used interchangeably.
Definition at line 61 of file SampleProfReader.h.
|
inline |
Definition at line 63 of file SampleProfReader.h.
|
inlinevirtual |
Definition at line 66 of file SampleProfReader.h.
|
static |
Create a sample profile reader appropriate to the file format.
Create a sample profile reader based on the format of the input file.
| Filename | The file to open. |
| Reader | The reader to instantiate according to Filename's format. |
| C | The LLVM context to use to emit diagnostics. |
Definition at line 383 of file SampleProfReader.cpp.
References llvm::sampleprof::SampleProfileReaderBinary::hasFormat(), and setupMemoryBuffer().
| 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 141 of file SampleProfReader.cpp.
References I.
| 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 134 of file SampleProfReader.cpp.
|
inline |
|
inline |
Return the samples collected for function F.
Definition at line 81 of file SampleProfReader.h.
References llvm::Value::getName(), and Profiles.
|
pure virtual |
Read sample profiles from the associated file.
Implemented in llvm::sampleprof::SampleProfileReaderBinary, and llvm::sampleprof::SampleProfileReaderText.
|
pure virtual |
Read and validate the file header.
Implemented in llvm::sampleprof::SampleProfileReaderBinary, and llvm::sampleprof::SampleProfileReaderText.
|
inline |
Report a parse error message.
Definition at line 89 of file SampleProfReader.h.
References Buffer, Ctx, and llvm::LLVMContext::diagnose().
|
protected |
Memory buffer holding the profile file.
Definition at line 110 of file SampleProfReader.h.
Referenced by reportParseError().
|
protected |
LLVM context used to emit diagnostics.
Definition at line 107 of file SampleProfReader.h.
Referenced by reportParseError().
|
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 104 of file SampleProfReader.h.
Referenced by getProfiles(), and getSamplesFor().
1.8.6