SamplePGO - Move debug/dump function bodies out of header files. NFC.
authorDiego Novillo <dnovillo@google.com>
Tue, 17 Nov 2015 19:04:46 +0000 (19:04 +0000)
committerDiego Novillo <dnovillo@google.com>
Tue, 17 Nov 2015 19:04:46 +0000 (19:04 +0000)
No point polluting the header declarations with debugging code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253361 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ProfileData/SampleProf.h
lib/ProfileData/SampleProf.cpp

index 52cbba396a3382c5071700aea56824236dca529f..d7596d7b1b77340f924978caf5e9024c2957a5cf 100644 (file)
@@ -75,21 +75,14 @@ static inline uint64_t SPVersion() { return 102; }
 /// (e.g., the two post-increment instructions in "if (p) x++; else y++;").
 struct LineLocation {
   LineLocation(uint32_t L, uint32_t D) : LineOffset(L), Discriminator(D) {}
-  void print(raw_ostream &OS) const {
-    OS << LineOffset;
-    if (Discriminator > 0)
-      OS << "." << Discriminator;
-  }
-  void dump() const { print(dbgs()); }
+  void print(raw_ostream &OS) const;
+  void dump() const;
 
   uint32_t LineOffset;
   uint32_t Discriminator;
 };
 
-inline raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc) {
-  Loc.print(OS);
-  return OS;
-}
+raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc);
 
 /// Represents the relative location of a callsite.
 ///
@@ -100,19 +93,13 @@ inline raw_ostream &operator<<(raw_ostream &OS, const LineLocation &Loc) {
 struct CallsiteLocation : public LineLocation {
   CallsiteLocation(uint32_t L, uint32_t D, StringRef N)
       : LineLocation(L, D), CalleeName(N) {}
-  StringRef CalleeName;
+  void print(raw_ostream &OS) const;
+  void dump() const;
 
-  void print(raw_ostream &OS) const {
-    LineLocation::print(OS);
-    OS << ": inlined callee: " << CalleeName;
-  }
-  void dump() const { print(dbgs()); }
+  StringRef CalleeName;
 };
 
-inline raw_ostream &operator<<(raw_ostream &OS, const CallsiteLocation &Loc) {
-  Loc.print(OS);
-  return OS;
-}
+raw_ostream &operator<<(raw_ostream &OS, const CallsiteLocation &Loc);
 
 } // End namespace sampleprof
 
@@ -218,17 +205,14 @@ public:
   }
 
   void print(raw_ostream &OS, unsigned Indent) const;
-  void dump() const { print(dbgs(), 0); }
+  void dump() const;
 
 private:
   uint64_t NumSamples;
   CallTargetMap CallTargets;
 };
 
-inline raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample) {
-  Sample.print(OS, 0);
-  return OS;
-}
+raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);
 
 typedef DenseMap<LineLocation, SampleRecord> BodySampleMap;
 class FunctionSamples;
@@ -243,7 +227,7 @@ class FunctionSamples {
 public:
   FunctionSamples() : TotalSamples(0), TotalHeadSamples(0) {}
   void print(raw_ostream &OS = dbgs(), unsigned Indent = 0) const;
-  void dump(void) const { print(); }
+  void dump() const;
   void addTotalSamples(uint64_t Num) { TotalSamples += Num; }
   void addHeadSamples(uint64_t Num) { TotalHeadSamples += Num; }
   void addBodySamples(uint32_t LineOffset, uint32_t Discriminator,
@@ -355,10 +339,7 @@ private:
   CallsiteSampleMap CallsiteSamples;
 };
 
-inline raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS) {
-  FS.print(OS);
-  return OS;
-}
+raw_ostream &operator<<(raw_ostream &OS, const FunctionSamples &FS);
 
 } // end namespace sampleprof
 
index b3ee61a7b978e01d5144e8b359ff60fdefdca662..3d75d230fb6f0ee65a7d1e9ccb575f8201d354bf 100644 (file)
@@ -57,6 +57,33 @@ const std::error_category &llvm::sampleprof_category() {
   return *ErrorCategory;
 }
 
+void LineLocation::print(raw_ostream &OS) const {
+  OS << LineOffset;
+  if (Discriminator > 0)
+    OS << "." << Discriminator;
+}
+
+raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
+                                          const LineLocation &Loc) {
+  Loc.print(OS);
+  return OS;
+}
+
+void LineLocation::dump() const { print(dbgs()); }
+
+void CallsiteLocation::print(raw_ostream &OS) const {
+  LineLocation::print(OS);
+  OS << ": inlined callee: " << CalleeName;
+}
+
+void CallsiteLocation::dump() const { print(dbgs()); }
+
+inline raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
+                                                 const CallsiteLocation &Loc) {
+  Loc.print(OS);
+  return OS;
+}
+
 /// \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;
@@ -68,6 +95,14 @@ void SampleRecord::print(raw_ostream &OS, unsigned Indent) const {
   OS << "\n";
 }
 
+void SampleRecord::dump() const { print(dbgs(), 0); }
+
+raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
+                                          const SampleRecord &Sample) {
+  Sample.print(OS, 0);
+  return OS;
+}
+
 /// \brief Print the samples collected for a function on stream \p OS.
 void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
   OS << TotalSamples << ", " << TotalHeadSamples << ", " << BodySamples.size()
@@ -84,3 +119,11 @@ void FunctionSamples::print(raw_ostream &OS, unsigned Indent) const {
     CS.second.print(OS, Indent + 2);
   }
 }
+
+raw_ostream &llvm::sampleprof::operator<<(raw_ostream &OS,
+                                          const FunctionSamples &FS) {
+  FS.print(OS);
+  return OS;
+}
+
+void FunctionSamples::dump(void) const { print(dbgs(), 0); }