[llvm] r270143 - Remove specializations of ProfileSummary
Easwaran Raman via llvm-commits
llvm-commits at lists.llvm.org
Thu May 19 14:53:28 PDT 2016
Author: eraman
Date: Thu May 19 16:53:28 2016
New Revision: 270143
URL: http://llvm.org/viewvc/llvm-project?rev=270143&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/IR/ProfileSummary.h
llvm/trunk/include/llvm/ProfileData/InstrProfReader.h
llvm/trunk/include/llvm/ProfileData/ProfileCommon.h
llvm/trunk/include/llvm/ProfileData/SampleProfReader.h
llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h
llvm/trunk/lib/IR/ProfileSummary.cpp
llvm/trunk/lib/ProfileData/InstrProfReader.cpp
llvm/trunk/lib/ProfileData/InstrProfWriter.cpp
llvm/trunk/lib/ProfileData/ProfileSummaryBuilder.cpp
llvm/trunk/lib/ProfileData/SampleProfReader.cpp
llvm/trunk/lib/ProfileData/SampleProfWriter.cpp
llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
llvm/trunk/unittests/ProfileData/SampleProfTest.cpp
Modified: llvm/trunk/include/llvm/IR/ProfileSummary.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/ProfileSummary.h?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/ProfileSummary.h (original)
+++ llvm/trunk/include/llvm/IR/ProfileSummary.h Thu May 19 16:53:28 2016
@@ -50,29 +50,23 @@ public:
private:
const Kind PSK;
static const char *KindStr[2];
-
-protected:
SummaryEntryVector DetailedSummary;
- uint64_t TotalCount, MaxCount, MaxFunctionCount;
+ uint64_t TotalCount, MaxCount, MaxInternalCount, MaxFunctionCount;
uint32_t NumCounts, NumFunctions;
- ProfileSummary(Kind K, SummaryEntryVector DetailedSummary,
- uint64_t TotalCount, uint64_t MaxCount,
- uint64_t MaxFunctionCount, uint32_t NumCounts,
- uint32_t NumFunctions)
- : PSK(K), DetailedSummary(DetailedSummary), TotalCount(TotalCount),
- MaxCount(MaxCount), MaxFunctionCount(MaxFunctionCount),
- NumCounts(NumCounts), NumFunctions(NumFunctions) {}
- ~ProfileSummary() = default;
- /// \brief Return metadata specific to the profile format.
- /// Derived classes implement this method to return a vector of Metadata.
- virtual std::vector<Metadata *> getFormatSpecificMD(LLVMContext &Context) = 0;
/// \brief Return detailed summary as metadata.
Metadata *getDetailedSummaryMD(LLVMContext &Context);
public:
static const int Scale = 1000000;
+ ProfileSummary(Kind K, SummaryEntryVector DetailedSummary,
+ uint64_t TotalCount, uint64_t MaxCount,
+ uint64_t MaxInternalCount, uint64_t MaxFunctionCount,
+ uint32_t NumCounts, uint32_t NumFunctions)
+ : PSK(K), DetailedSummary(DetailedSummary), TotalCount(TotalCount),
+ MaxCount(MaxCount), MaxInternalCount(MaxInternalCount),
+ MaxFunctionCount(MaxFunctionCount), NumCounts(NumCounts),
+ NumFunctions(NumFunctions) {}
Kind getKind() const { return PSK; }
- const char *getKindStr() const { return KindStr[PSK]; }
/// \brief Return summary information as metadata.
Metadata *getMD(LLVMContext &Context);
/// \brief Construct profile summary from metdata.
@@ -80,49 +74,10 @@ public:
SummaryEntryVector &getDetailedSummary() { return DetailedSummary; }
uint32_t getNumFunctions() { return NumFunctions; }
uint64_t getMaxFunctionCount() { return MaxFunctionCount; }
-};
-
-class InstrProfSummary final : public ProfileSummary {
- uint64_t MaxInternalBlockCount;
-
-protected:
- std::vector<Metadata *> getFormatSpecificMD(LLVMContext &Context) override;
-
-public:
- InstrProfSummary(uint64_t TotalCount, uint64_t MaxBlockCount,
- uint64_t MaxInternalBlockCount, uint64_t MaxFunctionCount,
- uint32_t NumBlocks, uint32_t NumFunctions,
- SummaryEntryVector Summary)
- : ProfileSummary(PSK_Instr, Summary, TotalCount, MaxBlockCount,
- MaxFunctionCount, NumBlocks, NumFunctions),
- MaxInternalBlockCount(MaxInternalBlockCount) {}
- static bool classof(const ProfileSummary *PS) {
- return PS->getKind() == PSK_Instr;
- }
- uint32_t getNumBlocks() { return NumCounts; }
+ uint32_t getNumCounts() { return NumCounts; }
uint64_t getTotalCount() { return TotalCount; }
- uint64_t getMaxBlockCount() { return MaxCount; }
- uint64_t getMaxInternalBlockCount() { return MaxInternalBlockCount; }
-};
-
-class SampleProfileSummary final : public ProfileSummary {
-protected:
- std::vector<Metadata *> getFormatSpecificMD(LLVMContext &Context) override;
-
-public:
- uint32_t getNumLinesWithSamples() { return NumCounts; }
- uint64_t getTotalSamples() { return TotalCount; }
- uint64_t getMaxSamplesPerLine() { return MaxCount; }
- SampleProfileSummary(uint64_t TotalSamples, uint64_t MaxSamplesPerLine,
- uint64_t MaxFunctionCount, int32_t NumLinesWithSamples,
- uint32_t NumFunctions,
- SummaryEntryVector DetailedSummary)
- : ProfileSummary(PSK_Sample, DetailedSummary, TotalSamples,
- MaxSamplesPerLine, MaxFunctionCount, NumLinesWithSamples,
- NumFunctions) {}
- static bool classof(const ProfileSummary *PS) {
- return PS->getKind() == PSK_Sample;
- }
+ uint64_t getMaxCount() { return MaxCount; }
+ uint64_t getMaxInternalCount() { return MaxInternalCount; }
};
} // end namespace llvm
Modified: llvm/trunk/include/llvm/ProfileData/InstrProfReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/InstrProfReader.h?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/InstrProfReader.h (original)
+++ llvm/trunk/include/llvm/ProfileData/InstrProfReader.h Thu May 19 16:53:28 2016
@@ -364,7 +364,7 @@ private:
/// The index into the profile data.
std::unique_ptr<InstrProfReaderIndexBase> Index;
/// Profile summary data.
- std::unique_ptr<InstrProfSummary> Summary;
+ std::unique_ptr<ProfileSummary> Summary;
IndexedInstrProfReader(const IndexedInstrProfReader &) = delete;
IndexedInstrProfReader &operator=(const IndexedInstrProfReader &) = delete;
@@ -417,7 +417,7 @@ public:
// to be used by llvm-profdata (for dumping). Avoid using this when
// the client is the compiler.
InstrProfSymtab &getSymtab() override;
- InstrProfSummary &getSummary() { return *(Summary.get()); }
+ ProfileSummary &getSummary() { return *(Summary.get()); }
};
} // end namespace llvm
Modified: llvm/trunk/include/llvm/ProfileData/ProfileCommon.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/ProfileCommon.h?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/ProfileCommon.h (original)
+++ llvm/trunk/include/llvm/ProfileData/ProfileCommon.h Thu May 19 16:53:28 2016
@@ -74,7 +74,7 @@ public:
InstrProfSummaryBuilder(std::vector<uint32_t> Cutoffs)
: ProfileSummaryBuilder(Cutoffs), MaxInternalBlockCount(0) {}
void addRecord(const InstrProfRecord &);
- InstrProfSummary *getSummary();
+ ProfileSummary *getSummary();
};
class SampleProfileSummaryBuilder final : public ProfileSummaryBuilder {
@@ -83,7 +83,7 @@ public:
void addRecord(const sampleprof::FunctionSamples &FS);
SampleProfileSummaryBuilder(std::vector<uint32_t> Cutoffs)
: ProfileSummaryBuilder(Cutoffs) {}
- SampleProfileSummary *getSummary();
+ ProfileSummary *getSummary();
};
// This is called when a count is seen in the profile.
Modified: llvm/trunk/include/llvm/ProfileData/SampleProfReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProfReader.h?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/SampleProfReader.h (original)
+++ llvm/trunk/include/llvm/ProfileData/SampleProfReader.h Thu May 19 16:53:28 2016
@@ -296,7 +296,7 @@ public:
create(std::unique_ptr<MemoryBuffer> &B, LLVMContext &C);
/// \brief Return the profile summary.
- SampleProfileSummary &getSummary() { return *(Summary.get()); }
+ ProfileSummary &getSummary() { return *(Summary.get()); }
protected:
/// \brief Map every function to its associated profile.
@@ -313,7 +313,7 @@ protected:
std::unique_ptr<MemoryBuffer> Buffer;
/// \brief Profile summary information.
- std::unique_ptr<SampleProfileSummary> Summary;
+ std::unique_ptr<ProfileSummary> Summary;
/// \brief Compute summary for this profile.
void computeSummary();
Modified: llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h (original)
+++ llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h Thu May 19 16:53:28 2016
@@ -76,7 +76,7 @@ protected:
std::unique_ptr<raw_ostream> OutputStream;
/// \brief Profile summary.
- std::unique_ptr<SampleProfileSummary> Summary;
+ std::unique_ptr<ProfileSummary> Summary;
/// \brief Compute summary for this profile.
void computeSummary(const StringMap<FunctionSamples> &ProfileMap);
Modified: llvm/trunk/lib/IR/ProfileSummary.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ProfileSummary.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ProfileSummary.cpp (original)
+++ llvm/trunk/lib/IR/ProfileSummary.cpp Thu May 19 16:53:28 2016
@@ -70,50 +70,18 @@ Metadata *ProfileSummary::getDetailedSum
// to the kind of profile summary as returned by getFormatSpecificMD.
Metadata *ProfileSummary::getMD(LLVMContext &Context) {
std::vector<Metadata *> Components;
- Components.push_back(getKeyValMD(Context, "ProfileFormat", getKindStr()));
- std::vector<Metadata *> Res = getFormatSpecificMD(Context);
- Components.insert(Components.end(), Res.begin(), Res.end());
- return MDTuple::get(Context, Components);
-}
-
-// Returns a vector of MDTuples specific to InstrProfSummary. The first six
-// elements of this vector are (Key, Val) pairs of the six scalar fields of
-// InstrProfSummary (TotalCount, MaxBlockCount, MaxInternalBlockCount,
-// MaxFunctionCount, NumBlocks, NumFunctions). The last element of this vector
-// is an MDTuple returned by getDetailedSummaryMD.
-std::vector<Metadata *>
-InstrProfSummary::getFormatSpecificMD(LLVMContext &Context) {
- std::vector<Metadata *> Components;
+ Components.push_back(getKeyValMD(Context, "ProfileFormat", KindStr[PSK]));
Components.push_back(getKeyValMD(Context, "TotalCount", getTotalCount()));
+ Components.push_back(getKeyValMD(Context, "MaxCount", getMaxCount()));
Components.push_back(
- getKeyValMD(Context, "MaxBlockCount", getMaxBlockCount()));
- Components.push_back(getKeyValMD(Context, "MaxInternalBlockCount",
- getMaxInternalBlockCount()));
+ getKeyValMD(Context, "MaxInternalCount", getMaxInternalCount()));
Components.push_back(
getKeyValMD(Context, "MaxFunctionCount", getMaxFunctionCount()));
- Components.push_back(getKeyValMD(Context, "NumBlocks", getNumBlocks()));
+ Components.push_back(getKeyValMD(Context, "NumCounts", getNumCounts()));
Components.push_back(getKeyValMD(Context, "NumFunctions", getNumFunctions()));
-
- Components.push_back(getDetailedSummaryMD(Context));
- return Components;
-}
-
-std::vector<Metadata *>
-SampleProfileSummary::getFormatSpecificMD(LLVMContext &Context) {
- std::vector<Metadata *> Components;
-
- Components.push_back(getKeyValMD(Context, "TotalSamples", getTotalSamples()));
- Components.push_back(
- getKeyValMD(Context, "MaxSamplesPerLine", getMaxSamplesPerLine()));
- Components.push_back(
- getKeyValMD(Context, "MaxFunctionCount", getMaxFunctionCount()));
- Components.push_back(
- getKeyValMD(Context, "NumLinesWithSamples", getNumLinesWithSamples()));
- Components.push_back(getKeyValMD(Context, "NumFunctions", NumFunctions));
-
Components.push_back(getDetailedSummaryMD(Context));
- return Components;
+ return MDTuple::get(Context, Components);
}
// Parse an MDTuple representing (Key, Val) pair.
@@ -175,83 +143,47 @@ static bool getSummaryFromMD(MDTuple *MD
return true;
}
-// Parse an MDTuple representing an InstrProfSummary object.
-static ProfileSummary *getInstrProfSummaryFromMD(MDTuple *Tuple) {
- uint64_t NumBlocks, TotalCount, NumFunctions, MaxFunctionCount, MaxBlockCount,
- MaxInternalBlockCount;
- SummaryEntryVector Summary;
-
+ProfileSummary *ProfileSummary::getFromMD(Metadata *MD) {
+ if (!isa<MDTuple>(MD))
+ return nullptr;
+ MDTuple *Tuple = cast<MDTuple>(MD);
if (Tuple->getNumOperands() != 8)
return nullptr;
- // Skip operand 0 which has been already parsed in the caller
+ auto &FormatMD = Tuple->getOperand(0);
+ ProfileSummary::Kind SummaryKind;
+ if (isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD), "ProfileFormat",
+ "SampleProfile"))
+ SummaryKind = PSK_Sample;
+ else if (isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD), "ProfileFormat",
+ "InstrProf"))
+ SummaryKind = PSK_Instr;
+ else
+ return nullptr;
+
+ uint64_t NumCounts, TotalCount, NumFunctions, MaxFunctionCount, MaxCount,
+ MaxInternalCount;
if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(1)), "TotalCount",
TotalCount))
return nullptr;
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(2)), "MaxBlockCount",
- MaxBlockCount))
+ if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(2)), "MaxCount", MaxCount))
return nullptr;
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(3)), "MaxInternalBlockCount",
- MaxInternalBlockCount))
+ if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(3)), "MaxInternalCount",
+ MaxInternalCount))
return nullptr;
if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(4)), "MaxFunctionCount",
MaxFunctionCount))
return nullptr;
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(5)), "NumBlocks", NumBlocks))
+ if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(5)), "NumCounts", NumCounts))
return nullptr;
if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(6)), "NumFunctions",
NumFunctions))
return nullptr;
- if (!getSummaryFromMD(dyn_cast<MDTuple>(Tuple->getOperand(7)), Summary))
- return nullptr;
- return new InstrProfSummary(TotalCount, MaxBlockCount, MaxInternalBlockCount,
- MaxFunctionCount, NumBlocks, NumFunctions,
- Summary);
-}
-// Parse an MDTuple representing a SampleProfileSummary object.
-static ProfileSummary *getSampleProfileSummaryFromMD(MDTuple *Tuple) {
- uint64_t TotalSamples, MaxSamplesPerLine, MaxFunctionCount,
- NumLinesWithSamples, NumFunctions;
SummaryEntryVector Summary;
-
- if (Tuple->getNumOperands() != 7)
- return nullptr;
-
- // Skip operand 0 which has been already parsed in the caller
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(1)), "TotalSamples",
- TotalSamples))
- return nullptr;
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(2)), "MaxSamplesPerLine",
- MaxSamplesPerLine))
- return nullptr;
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(3)), "MaxFunctionCount",
- MaxFunctionCount))
- return nullptr;
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(4)), "NumLinesWithSamples",
- NumLinesWithSamples))
- return nullptr;
- if (!getVal(dyn_cast<MDTuple>(Tuple->getOperand(5)), "NumFunctions",
- NumFunctions))
- return nullptr;
- if (!getSummaryFromMD(dyn_cast<MDTuple>(Tuple->getOperand(6)), Summary))
- return nullptr;
- return new SampleProfileSummary(TotalSamples, MaxSamplesPerLine,
- MaxFunctionCount, NumLinesWithSamples,
- NumFunctions, Summary);
-}
-
-ProfileSummary *ProfileSummary::getFromMD(Metadata *MD) {
- if (!isa<MDTuple>(MD))
- return nullptr;
- MDTuple *Tuple = cast<MDTuple>(MD);
- auto &FormatMD = Tuple->getOperand(0);
- if (isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD), "ProfileFormat",
- "SampleProfile"))
- return getSampleProfileSummaryFromMD(Tuple);
- else if (isKeyValuePair(dyn_cast_or_null<MDTuple>(FormatMD), "ProfileFormat",
- "InstrProf"))
- return getInstrProfSummaryFromMD(Tuple);
- else
+ if (!getSummaryFromMD(dyn_cast<MDTuple>(Tuple->getOperand(7)), Summary))
return nullptr;
+ return new ProfileSummary(SummaryKind, Summary, TotalCount, MaxCount,
+ MaxInternalCount, MaxFunctionCount, NumCounts,
+ NumFunctions);
}
Modified: llvm/trunk/lib/ProfileData/InstrProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfReader.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp Thu May 19 16:53:28 2016
@@ -602,13 +602,14 @@ IndexedInstrProfReader::readSummary(Inde
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:
Modified: llvm/trunk/lib/ProfileData/InstrProfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/InstrProfWriter.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/InstrProfWriter.cpp (original)
+++ llvm/trunk/lib/ProfileData/InstrProfWriter.cpp Thu May 19 16:53:28 2016
@@ -195,17 +195,16 @@ bool InstrProfWriter::shouldEncodeData(c
}
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 @@ void InstrProfWriter::writeImpl(ProfOStr
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:
Modified: llvm/trunk/lib/ProfileData/ProfileSummaryBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/ProfileSummaryBuilder.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/ProfileSummaryBuilder.cpp (original)
+++ llvm/trunk/lib/ProfileData/ProfileSummaryBuilder.cpp Thu May 19 16:53:28 2016
@@ -86,17 +86,18 @@ void ProfileSummaryBuilder::computeDetai
}
}
-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) {
Modified: llvm/trunk/lib/ProfileData/SampleProfReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfReader.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/SampleProfReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/SampleProfReader.cpp Thu May 19 16:53:28 2016
@@ -470,9 +470,9 @@ std::error_code SampleProfileReaderBinar
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;
}
Modified: llvm/trunk/lib/ProfileData/SampleProfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/SampleProfWriter.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/SampleProfWriter.cpp (original)
+++ llvm/trunk/lib/ProfileData/SampleProfWriter.cpp Thu May 19 16:53:28 2016
@@ -138,10 +138,10 @@ std::error_code SampleProfileWriterBinar
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);
Modified: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp (original)
+++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp Thu May 19 16:53:28 2016
@@ -353,17 +353,16 @@ static int showInstrProfile(std::string
if (ShowCounts && TextFormat)
return 0;
- std::unique_ptr<InstrProfSummary> PS(Builder.getSummary());
+ std::unique_ptr<ProfileSummary> PS(Builder.getSummary());
if (ShowAllFunctions || !ShowFunction.empty())
OS << "Functions shown: " << ShownFunctions << "\n";
OS << "Total functions: " << PS->getNumFunctions() << "\n";
OS << "Maximum function count: " << PS->getMaxFunctionCount() << "\n";
- OS << "Maximum internal block count: " << PS->getMaxInternalBlockCount()
- << "\n";
+ OS << "Maximum internal block count: " << PS->getMaxInternalCount() << "\n";
if (ShowDetailedSummary) {
OS << "Detailed summary:\n";
- OS << "Total number of blocks: " << PS->getNumBlocks() << "\n";
+ OS << "Total number of blocks: " << PS->getNumCounts() << "\n";
OS << "Total count: " << PS->getTotalCount() << "\n";
for (auto Entry : PS->getDetailedSummary()) {
OS << Entry.NumCounts << " blocks with count >= " << Entry.MinCount
Modified: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/InstrProfTest.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp Thu May 19 16:53:28 2016
@@ -156,10 +156,11 @@ TEST_F(InstrProfTest, get_profile_summar
auto Profile = Writer.writeBuffer();
readProfile(std::move(Profile));
- auto VerifySummary = [](InstrProfSummary &IPS) mutable {
+ auto VerifySummary = [](ProfileSummary &IPS) mutable {
+ ASSERT_EQ(ProfileSummary::PSK_Instr, IPS.getKind());
ASSERT_EQ(2305843009213693952U, IPS.getMaxFunctionCount());
- ASSERT_EQ(2305843009213693952U, IPS.getMaxBlockCount());
- ASSERT_EQ(10U, IPS.getNumBlocks());
+ ASSERT_EQ(2305843009213693952U, IPS.getMaxCount());
+ ASSERT_EQ(10U, IPS.getNumCounts());
ASSERT_EQ(4539628424389557499U, IPS.getTotalCount());
std::vector<ProfileSummaryEntry> &Details = IPS.getDetailedSummary();
uint32_t Cutoff = 800000;
@@ -180,7 +181,7 @@ TEST_F(InstrProfTest, get_profile_summar
ASSERT_EQ(288230376151711744U, NinetyFivePerc->MinCount);
ASSERT_EQ(72057594037927936U, NinetyNinePerc->MinCount);
};
- InstrProfSummary &PS = Reader->getSummary();
+ ProfileSummary &PS = Reader->getSummary();
VerifySummary(PS);
// Test that conversion of summary to and from Metadata works.
@@ -189,10 +190,8 @@ TEST_F(InstrProfTest, get_profile_summar
ASSERT_TRUE(MD);
ProfileSummary *PSFromMD = ProfileSummary::getFromMD(MD);
ASSERT_TRUE(PSFromMD);
- ASSERT_TRUE(isa<InstrProfSummary>(PSFromMD));
- InstrProfSummary *IPS = cast<InstrProfSummary>(PSFromMD);
- VerifySummary(*IPS);
- delete IPS;
+ VerifySummary(*PSFromMD);
+ delete PSFromMD;
// Test that summary can be attached to and read back from module.
Module M("my_module", Context);
@@ -201,10 +200,8 @@ TEST_F(InstrProfTest, get_profile_summar
ASSERT_TRUE(MD);
PSFromMD = ProfileSummary::getFromMD(MD);
ASSERT_TRUE(PSFromMD);
- ASSERT_TRUE(isa<InstrProfSummary>(PSFromMD));
- IPS = cast<InstrProfSummary>(PSFromMD);
- VerifySummary(*IPS);
- delete IPS;
+ VerifySummary(*PSFromMD);
+ delete PSFromMD;
}
static const char callee1[] = "callee1";
Modified: llvm/trunk/unittests/ProfileData/SampleProfTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ProfileData/SampleProfTest.cpp?rev=270143&r1=270142&r2=270143&view=diff
==============================================================================
--- llvm/trunk/unittests/ProfileData/SampleProfTest.cpp (original)
+++ llvm/trunk/unittests/ProfileData/SampleProfTest.cpp Thu May 19 16:53:28 2016
@@ -111,12 +111,13 @@ struct SampleProfTest : ::testing::Test
ASSERT_EQ(20301u, ReadBarSamples.getTotalSamples());
ASSERT_EQ(1437u, ReadBarSamples.getHeadSamples());
- auto VerifySummary = [](SampleProfileSummary &Summary) mutable {
- ASSERT_EQ(123603u, Summary.getTotalSamples());
- ASSERT_EQ(6u, Summary.getNumLinesWithSamples());
+ auto VerifySummary = [](ProfileSummary &Summary) mutable {
+ ASSERT_EQ(ProfileSummary::PSK_Sample, Summary.getKind());
+ ASSERT_EQ(123603u, Summary.getTotalCount());
+ ASSERT_EQ(6u, Summary.getNumCounts());
ASSERT_EQ(2u, Summary.getNumFunctions());
ASSERT_EQ(1437u, Summary.getMaxFunctionCount());
- ASSERT_EQ(60351u, Summary.getMaxSamplesPerLine());
+ ASSERT_EQ(60351u, Summary.getMaxCount());
uint32_t Cutoff = 800000;
auto Predicate = [&Cutoff](const ProfileSummaryEntry &PE) {
@@ -138,7 +139,7 @@ struct SampleProfTest : ::testing::Test
ASSERT_EQ(610u, NinetyNinePerc->MinCount);
};
- SampleProfileSummary &Summary = Reader->getSummary();
+ ProfileSummary &Summary = Reader->getSummary();
VerifySummary(Summary);
// Test that conversion of summary to and from Metadata works.
@@ -146,10 +147,8 @@ struct SampleProfTest : ::testing::Test
ASSERT_TRUE(MD);
ProfileSummary *PS = ProfileSummary::getFromMD(MD);
ASSERT_TRUE(PS);
- ASSERT_TRUE(isa<SampleProfileSummary>(PS));
- SampleProfileSummary *SPS = cast<SampleProfileSummary>(PS);
- VerifySummary(*SPS);
- delete SPS;
+ VerifySummary(*PS);
+ delete PS;
// Test that summary can be attached to and read back from module.
Module M("my_module", Context);
@@ -158,10 +157,8 @@ struct SampleProfTest : ::testing::Test
ASSERT_TRUE(MD);
PS = ProfileSummary::getFromMD(MD);
ASSERT_TRUE(PS);
- ASSERT_TRUE(isa<SampleProfileSummary>(PS));
- SPS = cast<SampleProfileSummary>(PS);
- VerifySummary(*SPS);
- delete SPS;
+ VerifySummary(*PS);
+ delete PS;
}
};
More information about the llvm-commits
mailing list