mirror of
https://github.com/RPCS3/llvm.git
synced 2025-03-05 00:59:19 +00:00
SamplePGO - Move debug/dump function bodies out of header files. NFC.
No point polluting the header declarations with debugging code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253361 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
034f865664
commit
64725c314d
@ -75,21 +75,14 @@ static inline uint64_t SPVersion() { return 102; }
|
||||
/// (e.g., the two post-increment instructions in "if (p) x++; else y++;").
|
||||
struct LineLocation {
|
||||
LineLocation(uint32_t L, uint32_t D) : LineOffset(L), Discriminator(D) {}
|
||||
void print(raw_ostream &OS) const {
|
||||
OS << LineOffset;
|
||||
if (Discriminator > 0)
|
||||
OS << "." << Discriminator;
|
||||
}
|
||||
void dump() const { print(dbgs()); }
|
||||
void print(raw_ostream &OS) const;
|
||||
void dump() const;
|
||||
|
||||
uint32_t LineOffset;
|
||||
uint32_t Discriminator;
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc) {
|
||||
Loc.print(OS);
|
||||
return OS;
|
||||
}
|
||||
raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc);
|
||||
|
||||
/// Represents the relative location of a callsite.
|
||||
///
|
||||
@ -100,19 +93,13 @@ inline raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc) {
|
||||
struct CallsiteLocation : public LineLocation {
|
||||
CallsiteLocation(uint32_t L, uint32_t D, StringRef N)
|
||||
: LineLocation(L, D), CalleeName(N) {}
|
||||
StringRef CalleeName;
|
||||
void print(raw_ostream &OS) const;
|
||||
void dump() const;
|
||||
|
||||
void print(raw_ostream &OS) const {
|
||||
LineLocation::print(OS);
|
||||
OS << ": inlined callee: " << CalleeName;
|
||||
}
|
||||
void dump() const { print(dbgs()); }
|
||||
StringRef CalleeName;
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const CallsiteLocation &Loc) {
|
||||
Loc.print(OS);
|
||||
return OS;
|
||||
}
|
||||
raw_ostream &operator<<(raw_ostream &OS, const CallsiteLocation &Loc);
|
||||
|
||||
} // End namespace sampleprof
|
||||
|
||||
@ -218,17 +205,14 @@ public:
|
||||
}
|
||||
|
||||
void print(raw_ostream &OS, unsigned Indent) const;
|
||||
void dump() const { print(dbgs(), 0); }
|
||||
void dump() const;
|
||||
|
||||
private:
|
||||
uint64_t NumSamples;
|
||||
CallTargetMap CallTargets;
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample) {
|
||||
Sample.print(OS, 0);
|
||||
return OS;
|
||||
}
|
||||
raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
|
||||
|
||||
typedef DenseMap<LineLocation, SampleRecord> BodySampleMap;
|
||||
class FunctionSamples;
|
||||
@ -243,7 +227,7 @@ class FunctionSamples {
|
||||
public:
|
||||
FunctionSamples() : TotalSamples(0), TotalHeadSamples(0) {}
|
||||
void print(raw_ostream &OS = dbgs(), unsigned Indent = 0) const;
|
||||
void dump(void) const { print(); }
|
||||
void dump() const;
|
||||
void addTotalSamples(uint64_t Num) { TotalSamples += Num; }
|
||||
void addHeadSamples(uint64_t Num) { TotalHeadSamples += Num; }
|
||||
void addBodySamples(uint32_t LineOffset, uint32_t Discriminator,
|
||||
@ -355,10 +339,7 @@ private:
|
||||
CallsiteSampleMap CallsiteSamples;
|
||||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS) {
|
||||
FS.print(OS);
|
||||
return OS;
|
||||
}
|
||||
raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);
|
||||
|
||||
} // end namespace sampleprof
|
||||
|
||||
|
@ -57,6 +57,33 @@ const std::error_category &llvm::sampleprof_category() {
|
||||
return *ErrorCategory;
|
||||
}
|
||||
|
||||
void LineLocation::print(raw_ostream &OS) const {
|
||||
OS << LineOffset;
|
||||
if (Discriminator > 0)
|
||||
OS << "." << Discriminator;
|
||||
}
|
||||
|
||||
raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
|
||||
const LineLocation &Loc) {
|
||||
Loc.print(OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
void LineLocation::dump() const { print(dbgs()); }
|
||||
|
||||
void CallsiteLocation::print(raw_ostream &OS) const {
|
||||
LineLocation::print(OS);
|
||||
OS << ": inlined callee: " << CalleeName;
|
||||
}
|
||||
|
||||
void CallsiteLocation::dump() const { print(dbgs()); }
|
||||
|
||||
inline raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
|
||||
const CallsiteLocation &Loc) {
|
||||
Loc.print(OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
/// \brief Print the sample record to the stream \p OS indented by \p Indent.
|
||||
void SampleRecord::print(raw_ostream &OS, unsigned Indent) const {
|
||||
OS << NumSamples;
|
||||
@ -68,6 +95,14 @@ void SampleRecord::print(raw_ostream &OS, unsigned Indent) const {
|
||||
OS << "\n";
|
||||
}
|
||||
|
||||
void SampleRecord::dump() const { print(dbgs(), 0); }
|
||||
|
||||
raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
|
||||
const SampleRecord &Sample) {
|
||||
Sample.print(OS, 0);
|
||||
return OS;
|
||||
}
|
||||
|
||||
/// \brief Print the samples collected for a function on stream \p OS.
|
||||
void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
|
||||
OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
|
||||
@ -84,3 +119,11 @@ void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
|
||||
CS.second.print(OS, Indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
|
||||
const FunctionSamples &FS) {
|
||||
FS.print(OS);
|
||||
return OS;
|
||||
}
|
||||
|
||||
void FunctionSamples::dump(void) const { print(dbgs(), 0); }
|
||||
|
Loading…
x
Reference in New Issue
Block a user