[llvm] r253361 - SamplePGO - Move debug/dump function bodies out of header files. NFC.

Diego Novillo via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 17 11:04:46 PST 2015


Author: dnovillo
Date: Tue Nov 17 13:04:46 2015
New Revision: 253361

URL: http://llvm.org/viewvc/llvm-project?rev=253361&view=rev
Log:
SamplePGO - Move debug/dump function bodies out of header files. NFC.

No point polluting the header declarations with debugging code.

Modified:
    llvm/trunk/include/llvm/ProfileData/SampleProf.h
    llvm/trunk/lib/ProfileData/SampleProf.cpp

Modified: llvm/trunk/include/llvm/ProfileData/SampleProf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProf.h?rev=253361&r1=253360&r2=253361&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/SampleProf.h (original)
+++ llvm/trunk/include/llvm/ProfileData/SampleProf.h Tue Nov 17 13:04:46 2015
@@ -75,21 +75,14 @@ static inline uint64_t SPVersion() { ret
 /// (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_ostre
 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
 

Modified: llvm/trunk/lib/ProfileData/SampleProf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProf.cpp?rev=253361&r1=253360&r2=253361&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/SampleProf.cpp (original)
+++ llvm/trunk/lib/ProfileData/SampleProf.cpp Tue Nov 17 13:04:46 2015
@@ -57,6 +57,33 @@ const std::error_category &llvm::samplep
   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
   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
     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); }




More information about the llvm-commits mailing list