SamplePGO - Tweak debugging output for function samples. NFC.
authorDiego Novillo <dnovillo@google.com>
Thu, 19 Nov 2015 22:18:30 +0000 (22:18 +0000)
committerDiego Novillo <dnovillo@google.com>
Thu, 19 Nov 2015 22:18:30 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253612 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ProfileData/SampleProf.cpp

index c376a8bbd98d06ae68ef3a6f47e2299753245045..1b76367f4de25a2da2de6fd0f47a3d102b9e2d9e 100644 (file)
@@ -108,18 +108,33 @@ void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
   OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
      << " sampled lines\n";
 
   OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
      << " sampled lines\n";
 
-  SampleSorter<LineLocation, SampleRecord> SortedBodySamples(BodySamples);
-  for (const auto &SI : SortedBodySamples.get()) {
+  OS.indent(Indent);
+  if (BodySamples.size() > 0) {
+    OS << "Samples collected in the function's body {\n";
+    SampleSorter<LineLocation, SampleRecord> SortedBodySamples(BodySamples);
+    for (const auto &SI : SortedBodySamples.get()) {
+      OS.indent(Indent + 2);
+      OS << SI->first << ": " << SI->second;
+    }
     OS.indent(Indent);
     OS.indent(Indent);
-    OS << SI->first << ": " << SI->second;
+    OS << "}\n";
+  } else {
+    OS << "No samples collected in the function's body\n";
   }
 
   }
 
-  SampleSorter<CallsiteLocation, FunctionSamples> SortedCallsiteSamples(
-      CallsiteSamples);
-  for (const auto &CS : SortedCallsiteSamples.get()) {
-    OS.indent(Indent);
-    OS << CS->first << ": ";
-    CS->second.print(OS, Indent + 2);
+  OS.indent(Indent);
+  if (CallsiteSamples.size() > 0) {
+    OS << "Samples collected in inlined callsites {\n";
+    SampleSorter<CallsiteLocation, FunctionSamples> SortedCallsiteSamples(
+        CallsiteSamples);
+    for (const auto &CS : SortedCallsiteSamples.get()) {
+      OS.indent(Indent + 2);
+      OS << CS->first << ": ";
+      CS->second.print(OS, Indent + 4);
+    }
+    OS << "}\n";
+  } else {
+    OS << "No inlined callsites in this function\n";
   }
 }
 
   }
 }