14 #ifndef LLVM_PROFILEDATA_SAMPLEPROF_H_
15 #define LLVM_PROFILEDATA_SAMPLEPROF_H_
22 #include <system_error>
51 namespace sampleprof {
54 return uint64_t(
'S') << (64 - 8) | uint64_t(
'P') << (64 - 16) |
55 uint64_t(
'R') << (64 - 24) | uint64_t(
'O') << (64 - 32) |
56 uint64_t(
'F') << (64 - 40) | uint64_t(
'4') << (64 - 48) |
57 uint64_t(
'2') << (64 - 56) | uint64_t(0xff);
84 DiscriminatorInfo::getEmptyKey());
88 DiscriminatorInfo::getTombstoneKey());
101 namespace sampleprof {
124 if (NumSamples <= std::numeric_limits<unsigned>::max() - S)
127 NumSamples = std::numeric_limits<unsigned>::max();
135 unsigned &TargetSamples = CallTargets[
F];
136 if (TargetSamples <= std::numeric_limits<unsigned>::max() - S)
139 TargetSamples = std::numeric_limits<unsigned>::max();
174 assert(LineOffset >= 0);
181 BodySamples[
LineLocation(LineOffset, Discriminator)].addSamples(Num);
184 std::string FName,
unsigned Num) {
185 assert(LineOffset >= 0);
186 BodySamples[
LineLocation(LineOffset, Discriminator)].addCalledTarget(FName,
193 return BodySamples[Loc];
198 unsigned samplesAt(
int LineOffset,
unsigned Discriminator) {
230 unsigned TotalSamples;
235 unsigned TotalHeadSamples;
249 #endif // LLVM_PROFILEDATA_SAMPLEPROF_H_
void addBodySamples(int LineOffset, unsigned Discriminator, unsigned Num)
unsigned getHeadSamples() const
Return the total number of samples collected at the head of the function.
const BodySampleMap & getBodySamples() const
Return all the samples collected in the body of the function.
static sampleprof::LineLocation getTombstoneKey()
void print(raw_ostream &OS=dbgs())
Print the samples collected for a function on stream OS.
void addTotalSamples(unsigned Num)
const CallTargetMap & getCallTargets() const
Representation of the samples collected for a function.
unsigned samplesAt(int LineOffset, unsigned Discriminator)
Return the number of samples collected at the given location.
std::error_code make_error_code(BitcodeError E)
Representation of a single sample record.
void addHeadSamples(unsigned Num)
static uint64_t SPVersion()
static ManagedStatic< _object_error_category > error_category
static unsigned getHashValue(sampleprof::LineLocation Val)
LineLocation(int L, unsigned D)
unsigned getTotalSamples() const
Return the total number of samples collected inside the function.
static bool isEqual(sampleprof::LineLocation LHS, sampleprof::LineLocation RHS)
DenseMap< LineLocation, SampleRecord > BodySampleMap
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const std::error_category & sampleprof_category()
DenseMapInfo< unsigned > DiscriminatorInfo
bool hasCalls() const
Return true if this sample record contains function calls.
StringMap< unsigned > CallTargetMap
static uint64_t SPMagic()
Represents the relative location of an instruction.
unsigned getSamples() const
DenseMapInfo< int > OffsetInfo
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
void addSamples(unsigned S)
Increment the number of samples for this record by S.
This class implements an extremely fast bulk output stream that can only output to a stream...
void addCalledTarget(StringRef F, unsigned S)
Add called function F with samples S.
static sampleprof::LineLocation getEmptyKey()
SampleRecord & sampleRecordAt(const LineLocation &Loc)
Return the sample record at the given location.
StringRef - Represent a constant reference to a string, i.e.
void merge(const FunctionSamples &Other)
Merge the samples in Other into this one.
void merge(const SampleRecord &Other)
Merge the samples in Other into this record.
void addCalledTargetSamples(int LineOffset, unsigned Discriminator, std::string FName, unsigned Num)