[llvm] r252915 - SamplePGO - Move FunctionSamples::print() to a better location. NFC.

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 12 09:58:15 PST 2015


Author: dnovillo
Date: Thu Nov 12 11:58:14 2015
New Revision: 252915

URL: http://llvm.org/viewvc/llvm-project?rev=252915&view=rev
Log:
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.

Modified:
    llvm/trunk/lib/ProfileData/SampleProf.cpp
    llvm/trunk/lib/ProfileData/SampleProfReader.cpp

Modified: llvm/trunk/lib/ProfileData/SampleProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProf.cpp?rev=252915&r1=252914&r2=252915&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/SampleProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/SampleProf.cpp Thu Nov 12 11:58:14 2015
@@ -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<SampleProfErrorCate
 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);
+  }
+}

Modified: llvm/trunk/lib/ProfileData/SampleProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfReader.cpp?rev=252915&r1=252914&r2=252915&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/SampleProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/SampleProfReader.cpp Thu Nov 12 11:58:14 2015
@@ -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.




More information about the llvm-commits mailing list