Remove specializations of ProfileSummary
This removes the subclasses of ProfileSummary, moves the members of the derived classes to the base class.
Differential Revision: http://reviews.llvm.org/D20390
llvm-svn: 270143
diff --git a/llvm/lib/ProfileData/InstrProfReader.cpp b/llvm/lib/ProfileData/InstrProfReader.cpp
index 33535fd..8ffdc5b 100644
--- a/llvm/lib/ProfileData/InstrProfReader.cpp
+++ b/llvm/lib/ProfileData/InstrProfReader.cpp
@@ -602,13 +602,14 @@
Ent.NumBlocks);
}
// initialize InstrProfSummary using the SummaryData from disk.
- this->Summary = llvm::make_unique<InstrProfSummary>(
+ this->Summary = llvm::make_unique<ProfileSummary>(
+ ProfileSummary::PSK_Instr, DetailedSummary,
SummaryData->get(Summary::TotalBlockCount),
SummaryData->get(Summary::MaxBlockCount),
SummaryData->get(Summary::MaxInternalBlockCount),
SummaryData->get(Summary::MaxFunctionCount),
SummaryData->get(Summary::TotalNumBlocks),
- SummaryData->get(Summary::TotalNumFunctions), DetailedSummary);
+ SummaryData->get(Summary::TotalNumFunctions));
return Cur + SummarySize;
} else {
// For older version of profile data, we need to compute on the fly:
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index 1036a10..e9543ce 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -195,17 +195,16 @@
}
static void setSummary(IndexedInstrProf::Summary *TheSummary,
- InstrProfSummary &PS) {
+ ProfileSummary &PS) {
using namespace IndexedInstrProf;
std::vector<ProfileSummaryEntry> &Res = PS.getDetailedSummary();
TheSummary->NumSummaryFields = Summary::NumKinds;
TheSummary->NumCutoffEntries = Res.size();
TheSummary->set(Summary::MaxFunctionCount, PS.getMaxFunctionCount());
- TheSummary->set(Summary::MaxBlockCount, PS.getMaxBlockCount());
- TheSummary->set(Summary::MaxInternalBlockCount,
- PS.getMaxInternalBlockCount());
+ TheSummary->set(Summary::MaxBlockCount, PS.getMaxCount());
+ TheSummary->set(Summary::MaxInternalBlockCount, PS.getMaxInternalCount());
TheSummary->set(Summary::TotalBlockCount, PS.getTotalCount());
- TheSummary->set(Summary::TotalNumBlocks, PS.getNumBlocks());
+ TheSummary->set(Summary::TotalNumBlocks, PS.getNumCounts());
TheSummary->set(Summary::TotalNumFunctions, PS.getNumFunctions());
for (unsigned I = 0; I < Res.size(); I++)
TheSummary->setEntry(I, Res[I]);
@@ -260,8 +259,8 @@
IndexedInstrProf::allocSummary(SummarySize);
// Compute the Summary and copy the data to the data
// structure to be serialized out (to disk or buffer).
- InstrProfSummary *IPS = ISB.getSummary();
- setSummary(TheSummary.get(), *IPS);
+ ProfileSummary *PS = ISB.getSummary();
+ setSummary(TheSummary.get(), *PS);
InfoObj->SummaryBuilder = 0;
// Now do the final patch:
diff --git a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
index 3d32722..ee40d68 100644
--- a/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
+++ b/llvm/lib/ProfileData/ProfileSummaryBuilder.cpp
@@ -86,17 +86,18 @@
}
}
-SampleProfileSummary *SampleProfileSummaryBuilder::getSummary() {
+ProfileSummary *SampleProfileSummaryBuilder::getSummary() {
computeDetailedSummary();
- return new SampleProfileSummary(TotalCount, MaxCount, MaxFunctionCount,
- NumCounts, NumFunctions, DetailedSummary);
+ return new ProfileSummary(ProfileSummary::PSK_Sample, DetailedSummary,
+ TotalCount, MaxCount, 0, MaxFunctionCount,
+ NumCounts, NumFunctions);
}
-InstrProfSummary *InstrProfSummaryBuilder::getSummary() {
+ProfileSummary *InstrProfSummaryBuilder::getSummary() {
computeDetailedSummary();
- return new InstrProfSummary(TotalCount, MaxCount, MaxInternalBlockCount,
- MaxFunctionCount, NumCounts, NumFunctions,
- DetailedSummary);
+ return new ProfileSummary(ProfileSummary::PSK_Instr, DetailedSummary,
+ TotalCount, MaxCount, MaxInternalBlockCount,
+ MaxFunctionCount, NumCounts, NumFunctions);
}
void InstrProfSummaryBuilder::addEntryCount(uint64_t Count) {
diff --git a/llvm/lib/ProfileData/SampleProfReader.cpp b/llvm/lib/ProfileData/SampleProfReader.cpp
index 14023bb..bd5aacc 100644
--- a/llvm/lib/ProfileData/SampleProfReader.cpp
+++ b/llvm/lib/ProfileData/SampleProfReader.cpp
@@ -470,9 +470,9 @@
if (EC != sampleprof_error::success)
return EC;
}
- Summary = llvm::make_unique<SampleProfileSummary>(
- *TotalCount, *MaxBlockCount, *MaxFunctionCount, *NumBlocks, *NumFunctions,
- Entries);
+ Summary = llvm::make_unique<ProfileSummary>(
+ ProfileSummary::PSK_Sample, Entries, *TotalCount, *MaxBlockCount, 0,
+ *MaxFunctionCount, *NumBlocks, *NumFunctions);
return sampleprof_error::success;
}
diff --git a/llvm/lib/ProfileData/SampleProfWriter.cpp b/llvm/lib/ProfileData/SampleProfWriter.cpp
index 56e836c..9c58f9e 100644
--- a/llvm/lib/ProfileData/SampleProfWriter.cpp
+++ b/llvm/lib/ProfileData/SampleProfWriter.cpp
@@ -138,10 +138,10 @@
std::error_code SampleProfileWriterBinary::writeSummary() {
auto &OS = *OutputStream;
- encodeULEB128(Summary->getTotalSamples(), OS);
- encodeULEB128(Summary->getMaxSamplesPerLine(), OS);
+ encodeULEB128(Summary->getTotalCount(), OS);
+ encodeULEB128(Summary->getMaxCount(), OS);
encodeULEB128(Summary->getMaxFunctionCount(), OS);
- encodeULEB128(Summary->getNumLinesWithSamples(), OS);
+ encodeULEB128(Summary->getNumCounts(), OS);
encodeULEB128(Summary->getNumFunctions(), OS);
std::vector<ProfileSummaryEntry> &Entries = Summary->getDetailedSummary();
encodeULEB128(Entries.size(), OS);