Skip to content

Commit 4b6bdb5

Browse files
author
Diego Novillo
committed
SamplePGO - Move FunctionSamples::print() to a better location. NFC.
The class is declared in SampleProf.h, so a better home for this is SampleProf.cpp. llvm-svn: 252915
1 parent 74b396d commit 4b6bdb5

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

llvm/lib/ProfileData/SampleProf.cpp

+32
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "llvm/Support/ErrorHandling.h"
1717
#include "llvm/Support/ManagedStatic.h"
1818

19+
using namespace llvm::sampleprof;
1920
using namespace llvm;
2021

2122
namespace {
@@ -55,3 +56,34 @@ static ManagedStatic<SampleProfErrorCategoryType> ErrorCategory;
5556
const std::error_category &llvm::sampleprof_category() {
5657
return *ErrorCategory;
5758
}
59+
60+
/// \brief Print the samples collected for a function on stream \p OS.
61+
///
62+
/// \param OS Stream to emit the output to.
63+
void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
64+
OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
65+
<< " sampled lines\n";
66+
for (const auto &SI : BodySamples) {
67+
LineLocation Loc = SI.first;
68+
const SampleRecord &Sample = SI.second;
69+
OS.indent(Indent);
70+
OS << "line offset: " << Loc.LineOffset
71+
<< ", discriminator: " << Loc.Discriminator
72+
<< ", number of samples: " << Sample.getSamples();
73+
if (Sample.hasCalls()) {
74+
OS << ", calls:";
75+
for (const auto &I : Sample.getCallTargets())
76+
OS << " " << I.first() << ":" << I.second;
77+
}
78+
OS << "\n";
79+
}
80+
for (const auto &CS : CallsiteSamples) {
81+
CallsiteLocation Loc = CS.first;
82+
const FunctionSamples &CalleeSamples = CS.second;
83+
OS.indent(Indent);
84+
OS << "line offset: " << Loc.LineOffset
85+
<< ", discriminator: " << Loc.Discriminator
86+
<< ", inlined callee: " << Loc.CalleeName << ": ";
87+
CalleeSamples.print(OS, Indent + 2);
88+
}
89+
}

llvm/lib/ProfileData/SampleProfReader.cpp

-31
Original file line numberDiff line numberDiff line change
@@ -32,37 +32,6 @@
3232
using namespace llvm::sampleprof;
3333
using namespace llvm;
3434

35-
/// \brief Print the samples collected for a function on stream \p OS.
36-
///
37-
/// \param OS Stream to emit the output to.
38-
void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
39-
OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
40-
<< " sampled lines\n";
41-
for (const auto &SI : BodySamples) {
42-
LineLocation Loc = SI.first;
43-
const SampleRecord &Sample = SI.second;
44-
OS.indent(Indent);
45-
OS << "line offset: " << Loc.LineOffset
46-
<< ", discriminator: " << Loc.Discriminator
47-
<< ", number of samples: " << Sample.getSamples();
48-
if (Sample.hasCalls()) {
49-
OS << ", calls:";
50-
for (const auto &I : Sample.getCallTargets())
51-
OS << " " << I.first() << ":" << I.second;
52-
}
53-
OS << "\n";
54-
}
55-
for (const auto &CS : CallsiteSamples) {
56-
CallsiteLocation Loc = CS.first;
57-
const FunctionSamples &CalleeSamples = CS.second;
58-
OS.indent(Indent);
59-
OS << "line offset: " << Loc.LineOffset
60-
<< ", discriminator: " << Loc.Discriminator
61-
<< ", inlined callee: " << Loc.CalleeName << ": ";
62-
CalleeSamples.print(OS, Indent + 2);
63-
}
64-
}
65-
6635
/// \brief Dump the function profile for \p FName.
6736
///
6837
/// \param FName Name of the function to print.

0 commit comments

Comments
 (0)