소스 검색

Profile summary cleanup.

Differential Revision: http://reviews.llvm.org/D18468



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264619 91177308-0d34-0410-b5e6-96231b3b80d8
Easwaran Raman 9 년 전
부모
커밋
91fbac1a08
2개의 변경된 파일27개의 추가작업 그리고 29개의 파일을 삭제
  1. 21 24
      include/llvm/ProfileData/ProfileCommon.h
  2. 6 5
      lib/ProfileData/ProfileSummary.cpp

+ 21 - 24
include/llvm/ProfileData/ProfileCommon.h

@@ -71,16 +71,21 @@ private:
 protected:
 protected:
   SummaryEntryVector DetailedSummary;
   SummaryEntryVector DetailedSummary;
   std::vector<uint32_t> DetailedSummaryCutoffs;
   std::vector<uint32_t> DetailedSummaryCutoffs;
-  uint64_t TotalCount, MaxCount;
-  uint32_t NumCounts;
+  uint64_t TotalCount, MaxCount, MaxFunctionCount;
+  uint32_t NumCounts, NumFunctions;
   ProfileSummary(Kind K, std::vector<uint32_t> Cutoffs)
   ProfileSummary(Kind K, std::vector<uint32_t> Cutoffs)
       : PSK(K), DetailedSummaryCutoffs(Cutoffs), TotalCount(0), MaxCount(0),
       : PSK(K), DetailedSummaryCutoffs(Cutoffs), TotalCount(0), MaxCount(0),
-        NumCounts(0) {}
-  ProfileSummary(Kind K) : PSK(K), TotalCount(0), MaxCount(0), NumCounts(0) {}
+        MaxFunctionCount(0), NumCounts(0), NumFunctions(0) {}
+  ProfileSummary(Kind K)
+      : PSK(K), TotalCount(0), MaxCount(0), MaxFunctionCount(0), NumCounts(0),
+        NumFunctions(0) {}
   ProfileSummary(Kind K, SummaryEntryVector DetailedSummary,
   ProfileSummary(Kind K, SummaryEntryVector DetailedSummary,
-                 uint64_t TotalCount, uint64_t MaxCount, uint32_t NumCounts)
+                 uint64_t TotalCount, uint64_t MaxCount,
+                 uint64_t MaxFunctionCount, uint32_t NumCounts,
+                 uint32_t NumFunctions)
       : PSK(K), DetailedSummary(DetailedSummary), TotalCount(TotalCount),
       : PSK(K), DetailedSummary(DetailedSummary), TotalCount(TotalCount),
-        MaxCount(MaxCount), NumCounts(NumCounts) {}
+        MaxCount(MaxCount), MaxFunctionCount(MaxFunctionCount),
+        NumCounts(NumCounts), NumFunctions(NumFunctions) {}
   ~ProfileSummary() = default;
   ~ProfileSummary() = default;
   inline void addCount(uint64_t Count);
   inline void addCount(uint64_t Count);
   /// \brief Return metadata specific to the profile format.
   /// \brief Return metadata specific to the profile format.
@@ -105,11 +110,12 @@ public:
   Metadata *getMD(LLVMContext &Context);
   Metadata *getMD(LLVMContext &Context);
   /// \brief Construct profile summary from metdata.
   /// \brief Construct profile summary from metdata.
   static ProfileSummary *getFromMD(Metadata *MD);
   static ProfileSummary *getFromMD(Metadata *MD);
+  uint32_t getNumFunctions() { return NumFunctions; }
+  uint64_t getMaxFunctionCount() { return MaxFunctionCount; }
 };
 };
 
 
 class InstrProfSummary final : public ProfileSummary {
 class InstrProfSummary final : public ProfileSummary {
-  uint64_t MaxInternalBlockCount, MaxFunctionCount;
-  uint32_t NumFunctions;
+  uint64_t MaxInternalBlockCount;
   inline void addEntryCount(uint64_t Count);
   inline void addEntryCount(uint64_t Count);
   inline void addInternalCount(uint64_t Count);
   inline void addInternalCount(uint64_t Count);
 
 
@@ -118,53 +124,44 @@ protected:
 
 
 public:
 public:
   InstrProfSummary(std::vector<uint32_t> Cutoffs)
   InstrProfSummary(std::vector<uint32_t> Cutoffs)
-      : ProfileSummary(PSK_Instr, Cutoffs), MaxInternalBlockCount(0),
-        MaxFunctionCount(0), NumFunctions(0) {}
+      : ProfileSummary(PSK_Instr, Cutoffs), MaxInternalBlockCount(0) {}
   InstrProfSummary(const IndexedInstrProf::Summary &S);
   InstrProfSummary(const IndexedInstrProf::Summary &S);
   InstrProfSummary(uint64_t TotalCount, uint64_t MaxBlockCount,
   InstrProfSummary(uint64_t TotalCount, uint64_t MaxBlockCount,
                    uint64_t MaxInternalBlockCount, uint64_t MaxFunctionCount,
                    uint64_t MaxInternalBlockCount, uint64_t MaxFunctionCount,
                    uint32_t NumBlocks, uint32_t NumFunctions,
                    uint32_t NumBlocks, uint32_t NumFunctions,
                    SummaryEntryVector Summary)
                    SummaryEntryVector Summary)
       : ProfileSummary(PSK_Instr, Summary, TotalCount, MaxBlockCount,
       : ProfileSummary(PSK_Instr, Summary, TotalCount, MaxBlockCount,
-                       NumBlocks),
-        MaxInternalBlockCount(MaxInternalBlockCount),
-        MaxFunctionCount(MaxFunctionCount), NumFunctions(NumFunctions) {}
+                       MaxFunctionCount, NumBlocks, NumFunctions),
+        MaxInternalBlockCount(MaxInternalBlockCount) {}
   static bool classof(const ProfileSummary *PS) {
   static bool classof(const ProfileSummary *PS) {
     return PS->getKind() == PSK_Instr;
     return PS->getKind() == PSK_Instr;
   }
   }
   void addRecord(const InstrProfRecord &);
   void addRecord(const InstrProfRecord &);
   uint32_t getNumBlocks() { return NumCounts; }
   uint32_t getNumBlocks() { return NumCounts; }
   uint64_t getTotalCount() { return TotalCount; }
   uint64_t getTotalCount() { return TotalCount; }
-  uint32_t getNumFunctions() { return NumFunctions; }
-  uint64_t getMaxFunctionCount() { return MaxFunctionCount; }
   uint64_t getMaxBlockCount() { return MaxCount; }
   uint64_t getMaxBlockCount() { return MaxCount; }
   uint64_t getMaxInternalBlockCount() { return MaxInternalBlockCount; }
   uint64_t getMaxInternalBlockCount() { return MaxInternalBlockCount; }
 };
 };
 
 
 class SampleProfileSummary final : public ProfileSummary {
 class SampleProfileSummary final : public ProfileSummary {
-  uint64_t MaxHeadSamples;
-  uint32_t NumFunctions;
-
 protected:
 protected:
   std::vector<Metadata *> getFormatSpecificMD(LLVMContext &Context) override;
   std::vector<Metadata *> getFormatSpecificMD(LLVMContext &Context) override;
 
 
 public:
 public:
   uint32_t getNumLinesWithSamples() { return NumCounts; }
   uint32_t getNumLinesWithSamples() { return NumCounts; }
   uint64_t getTotalSamples() { return TotalCount; }
   uint64_t getTotalSamples() { return TotalCount; }
-  uint32_t getNumFunctions() { return NumFunctions; }
-  uint64_t getMaxHeadSamples() { return MaxHeadSamples; }
+  uint64_t getMaxHeadSamples() { return MaxFunctionCount; }
   uint64_t getMaxSamplesPerLine() { return MaxCount; }
   uint64_t getMaxSamplesPerLine() { return MaxCount; }
   void addRecord(const sampleprof::FunctionSamples &FS);
   void addRecord(const sampleprof::FunctionSamples &FS);
   SampleProfileSummary(std::vector<uint32_t> Cutoffs)
   SampleProfileSummary(std::vector<uint32_t> Cutoffs)
-      : ProfileSummary(PSK_Sample, Cutoffs), MaxHeadSamples(0),
-        NumFunctions(0) {}
+      : ProfileSummary(PSK_Sample, Cutoffs) {}
   SampleProfileSummary(uint64_t TotalSamples, uint64_t MaxSamplesPerLine,
   SampleProfileSummary(uint64_t TotalSamples, uint64_t MaxSamplesPerLine,
                        uint64_t MaxHeadSamples, int32_t NumLinesWithSamples,
                        uint64_t MaxHeadSamples, int32_t NumLinesWithSamples,
                        uint32_t NumFunctions,
                        uint32_t NumFunctions,
                        SummaryEntryVector DetailedSummary)
                        SummaryEntryVector DetailedSummary)
       : ProfileSummary(PSK_Sample, DetailedSummary, TotalSamples,
       : ProfileSummary(PSK_Sample, DetailedSummary, TotalSamples,
-                       MaxSamplesPerLine, NumLinesWithSamples),
-        MaxHeadSamples(MaxHeadSamples), NumFunctions(NumFunctions) {}
+                       MaxSamplesPerLine, MaxHeadSamples, NumLinesWithSamples,
+                       NumFunctions) {}
   static bool classof(const ProfileSummary *PS) {
   static bool classof(const ProfileSummary *PS) {
     return PS->getKind() == PSK_Sample;
     return PS->getKind() == PSK_Sample;
   }
   }

+ 6 - 5
lib/ProfileData/ProfileSummary.cpp

@@ -42,8 +42,8 @@ void InstrProfSummary::addRecord(const InstrProfRecord &R) {
 // equivalent to a block with a count in the instrumented profile.
 // equivalent to a block with a count in the instrumented profile.
 void SampleProfileSummary::addRecord(const sampleprof::FunctionSamples &FS) {
 void SampleProfileSummary::addRecord(const sampleprof::FunctionSamples &FS) {
   NumFunctions++;
   NumFunctions++;
-  if (FS.getHeadSamples() > MaxHeadSamples)
-    MaxHeadSamples = FS.getHeadSamples();
+  if (FS.getHeadSamples() > MaxFunctionCount)
+    MaxFunctionCount = FS.getHeadSamples();
   for (const auto &I : FS.getBodySamples())
   for (const auto &I : FS.getBodySamples())
     addCount(I.second.getSamples());
     addCount(I.second.getSamples());
 }
 }
@@ -103,13 +103,13 @@ bool ProfileSummary::isFunctionUnlikely(const Function *F) {
 InstrProfSummary::InstrProfSummary(const IndexedInstrProf::Summary &S)
 InstrProfSummary::InstrProfSummary(const IndexedInstrProf::Summary &S)
     : ProfileSummary(PSK_Instr),
     : ProfileSummary(PSK_Instr),
       MaxInternalBlockCount(
       MaxInternalBlockCount(
-          S.get(IndexedInstrProf::Summary::MaxInternalBlockCount)),
-      MaxFunctionCount(S.get(IndexedInstrProf::Summary::MaxFunctionCount)),
-      NumFunctions(S.get(IndexedInstrProf::Summary::TotalNumFunctions)) {
+          S.get(IndexedInstrProf::Summary::MaxInternalBlockCount)) {
 
 
   TotalCount = S.get(IndexedInstrProf::Summary::TotalBlockCount);
   TotalCount = S.get(IndexedInstrProf::Summary::TotalBlockCount);
   MaxCount = S.get(IndexedInstrProf::Summary::MaxBlockCount);
   MaxCount = S.get(IndexedInstrProf::Summary::MaxBlockCount);
+  MaxFunctionCount = S.get(IndexedInstrProf::Summary::MaxFunctionCount);
   NumCounts = S.get(IndexedInstrProf::Summary::TotalNumBlocks);
   NumCounts = S.get(IndexedInstrProf::Summary::TotalNumBlocks);
+  NumFunctions = S.get(IndexedInstrProf::Summary::TotalNumFunctions);
 
 
   for (unsigned I = 0; I < S.NumCutoffEntries; I++) {
   for (unsigned I = 0; I < S.NumCutoffEntries; I++) {
     const IndexedInstrProf::Summary::Entry &Ent = S.getEntry(I);
     const IndexedInstrProf::Summary::Entry &Ent = S.getEntry(I);
@@ -117,6 +117,7 @@ InstrProfSummary::InstrProfSummary(const IndexedInstrProf::Summary &S)
                                  Ent.NumBlocks);
                                  Ent.NumBlocks);
   }
   }
 }
 }
+
 void InstrProfSummary::addEntryCount(uint64_t Count) {
 void InstrProfSummary::addEntryCount(uint64_t Count) {
   addCount(Count);
   addCount(Count);
   NumFunctions++;
   NumFunctions++;