[ARM] Allow TargetParser to accurately target architectures
[oota-llvm.git] / lib / ProfileData / SampleProf.cpp
index b5d3b2d2e551c9c03d7b10bdd3b34544a5277cc6..b3ee61a7b978e01d5144e8b359ff60fdefdca662 100644 (file)
@@ -28,17 +28,17 @@ class SampleProfErrorCategoryType : public std::error_category {
     case sampleprof_error::success:
       return "Success";
     case sampleprof_error::bad_magic:
-      return "Invalid file format (bad magic)";
+      return "Invalid sample profile data (bad magic)";
     case sampleprof_error::unsupported_version:
-      return "Unsupported format version";
+      return "Unsupported sample profile format version";
     case sampleprof_error::too_large:
       return "Too much profile data";
     case sampleprof_error::truncated:
       return "Truncated profile data";
     case sampleprof_error::malformed:
-      return "Malformed profile data";
+      return "Malformed sample profile data";
     case sampleprof_error::unrecognized_format:
-      return "Unrecognized profile encoding format";
+      return "Unrecognized sample profile encoding format";
     case sampleprof_error::unsupported_writing_format:
       return "Profile encoding format unsupported for writing operations";
     case sampleprof_error::truncated_name_table:
@@ -57,33 +57,30 @@ const std::error_category &llvm::sampleprof_category() {
   return *ErrorCategory;
 }
 
+/// \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;
+  if (hasCalls()) {
+    OS << ", calls:";
+    for (const auto &I : getCallTargets())
+      OS << " " << I.first() << ":" << I.second;
+  }
+  OS << "\n";
+}
+
 /// \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";
+    OS << SI.first << ": " << SI.second;
   }
+
   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);
+    OS << CS.first << ": ";
+    CS.second.print(OS, Indent + 2);
   }
 }