Skip to content

Commit

Permalink
SamplePGO - Move FunctionSamples::print() to a better location. NFC.
Browse files Browse the repository at this point in the history
The class is declared in SampleProf.h, so a better home for this is
SampleProf.cpp.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252915 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
dnovillo committed Nov 12, 2015
1 parent 2aca944 commit 7e02753
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 31 deletions.
32 changes: 32 additions & 0 deletions lib/ProfileData/SampleProf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"

using namespace llvm::sampleprof;
using namespace llvm;

namespace {
Expand Down Expand Up @@ -55,3 +56,34 @@ static ManagedStatic<SampleProfErrorCategoryType> ErrorCategory;
const std::error_category &llvm::sampleprof_category() {
return *ErrorCategory;
}

/// \brief Print the samples collected for a function on stream \p OS.
///
/// \param OS Stream to emit the output to.
void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
<< " sampled lines\n";
for (const auto &SI : BodySamples) {
LineLocation Loc = SI.first;
const SampleRecord &Sample = SI.second;
OS.indent(Indent);
OS << "line offset: " << Loc.LineOffset
<< ", discriminator: " << Loc.Discriminator
<< ", number of samples: " << Sample.getSamples();
if (Sample.hasCalls()) {
OS << ", calls:";
for (const auto &I : Sample.getCallTargets())
OS << " " << I.first() << ":" << I.second;
}
OS << "\n";
}
for (const auto &CS : CallsiteSamples) {
CallsiteLocation Loc = CS.first;
const FunctionSamples &CalleeSamples = CS.second;
OS.indent(Indent);
OS << "line offset: " << Loc.LineOffset
<< ", discriminator: " << Loc.Discriminator
<< ", inlined callee: " << Loc.CalleeName << ": ";
CalleeSamples.print(OS, Indent + 2);
}
}
31 changes: 0 additions & 31 deletions lib/ProfileData/SampleProfReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,6 @@
using namespace llvm::sampleprof;
using namespace llvm;

/// \brief Print the samples collected for a function on stream \p OS.
///
/// \param OS Stream to emit the output to.
void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
<< " sampled lines\n";
for (const auto &SI : BodySamples) {
LineLocation Loc = SI.first;
const SampleRecord &Sample = SI.second;
OS.indent(Indent);
OS << "line offset: " << Loc.LineOffset
<< ", discriminator: " << Loc.Discriminator
<< ", number of samples: " << Sample.getSamples();
if (Sample.hasCalls()) {
OS << ", calls:";
for (const auto &I : Sample.getCallTargets())
OS << " " << I.first() << ":" << I.second;
}
OS << "\n";
}
for (const auto &CS : CallsiteSamples) {
CallsiteLocation Loc = CS.first;
const FunctionSamples &CalleeSamples = CS.second;
OS.indent(Indent);
OS << "line offset: " << Loc.LineOffset
<< ", discriminator: " << Loc.Discriminator
<< ", inlined callee: " << Loc.CalleeName << ": ";
CalleeSamples.print(OS, Indent + 2);
}
}

/// \brief Dump the function profile for \p FName.
///
/// \param FName Name of the function to print.
Expand Down

0 comments on commit 7e02753

Please sign in to comment.