summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ProfileData/SampleProf.cpp32
-rw-r--r--llvm/lib/ProfileData/SampleProfReader.cpp31
2 files changed, 32 insertions, 31 deletions
diff --git a/llvm/lib/ProfileData/SampleProf.cpp b/llvm/lib/ProfileData/SampleProf.cpp
index c6960ba4bd9..b5d3b2d2e55 100644
--- a/llvm/lib/ProfileData/SampleProf.cpp
+++ b/llvm/lib/ProfileData/SampleProf.cpp
@@ -16,6 +16,7 @@
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
+using namespace llvm::sampleprof;
using namespace llvm;
namespace {
@@ -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);
+ }
+}
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index 899343f72f7..a5d00083b53 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -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.
OpenPOWER on IntegriCloud