Index: llvm/trunk/include/llvm/IR/ProfileSummary.h =================================================================== --- llvm/trunk/include/llvm/IR/ProfileSummary.h +++ llvm/trunk/include/llvm/IR/ProfileSummary.h @@ -50,29 +50,23 @@ 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 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 @@ 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 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 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 Index: llvm/trunk/include/llvm/ProfileData/InstrProfReader.h =================================================================== --- llvm/trunk/include/llvm/ProfileData/InstrProfReader.h +++ llvm/trunk/include/llvm/ProfileData/InstrProfReader.h @@ -364,7 +364,7 @@ /// The index into the profile data. std::unique_ptr Index; /// Profile summary data. - std::unique_ptr Summary; + std::unique_ptr Summary; IndexedInstrProfReader(const IndexedInstrProfReader &) = delete; IndexedInstrProfReader &operator=(const IndexedInstrProfReader &) = delete; @@ -417,7 +417,7 @@ // 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 Index: llvm/trunk/include/llvm/ProfileData/ProfileCommon.h =================================================================== --- llvm/trunk/include/llvm/ProfileData/ProfileCommon.h +++ llvm/trunk/include/llvm/ProfileData/ProfileCommon.h @@ -74,7 +74,7 @@ InstrProfSummaryBuilder(std::vector Cutoffs) : ProfileSummaryBuilder(Cutoffs), MaxInternalBlockCount(0) {} void addRecord(const InstrProfRecord &); - InstrProfSummary *getSummary(); + ProfileSummary *getSummary(); }; class SampleProfileSummaryBuilder final : public ProfileSummaryBuilder { @@ -83,7 +83,7 @@ void addRecord(const sampleprof::FunctionSamples &FS); SampleProfileSummaryBuilder(std::vector Cutoffs) : ProfileSummaryBuilder(Cutoffs) {} - SampleProfileSummary *getSummary(); + ProfileSummary *getSummary(); }; // This is called when a count is seen in the profile. Index: llvm/trunk/include/llvm/ProfileData/SampleProfReader.h =================================================================== --- llvm/trunk/include/llvm/ProfileData/SampleProfReader.h +++ llvm/trunk/include/llvm/ProfileData/SampleProfReader.h @@ -296,7 +296,7 @@ create(std::unique_ptr &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 @@ std::unique_ptr Buffer; /// \brief Profile summary information. - std::unique_ptr Summary; + std::unique_ptr Summary; /// \brief Compute summary for this profile. void computeSummary(); Index: llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h =================================================================== --- llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h +++ llvm/trunk/include/llvm/ProfileData/SampleProfWriter.h @@ -76,7 +76,7 @@ std::unique_ptr OutputStream; /// \brief Profile summary. - std::unique_ptr Summary; + std::unique_ptr Summary; /// \brief Compute summary for this profile. void computeSummary(const StringMap &ProfileMap); Index: llvm/trunk/lib/IR/ProfileSummary.cpp =================================================================== --- llvm/trunk/lib/IR/ProfileSummary.cpp +++ llvm/trunk/lib/IR/ProfileSummary.cpp @@ -70,50 +70,18 @@ // to the kind of profile summary as returned by getFormatSpecificMD. Metadata *ProfileSummary::getMD(LLVMContext &Context) { std::vector Components; - Components.push_back(getKeyValMD(Context, "ProfileFormat", getKindStr())); - std::vector 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 -InstrProfSummary::getFormatSpecificMD(LLVMContext &Context) { - std::vector 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 -SampleProfileSummary::getFormatSpecificMD(LLVMContext &Context) { - std::vector 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 @@ 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(MD)) + return nullptr; + MDTuple *Tuple = cast(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(FormatMD), "ProfileFormat", + "SampleProfile")) + SummaryKind = PSK_Sample; + else if (isKeyValuePair(dyn_cast_or_null(FormatMD), "ProfileFormat", + "InstrProf")) + SummaryKind = PSK_Instr; + else + return nullptr; + + uint64_t NumCounts, TotalCount, NumFunctions, MaxFunctionCount, MaxCount, + MaxInternalCount; if (!getVal(dyn_cast(Tuple->getOperand(1)), "TotalCount", TotalCount)) return nullptr; - if (!getVal(dyn_cast(Tuple->getOperand(2)), "MaxBlockCount", - MaxBlockCount)) + if (!getVal(dyn_cast(Tuple->getOperand(2)), "MaxCount", MaxCount)) return nullptr; - if (!getVal(dyn_cast(Tuple->getOperand(3)), "MaxInternalBlockCount", - MaxInternalBlockCount)) + if (!getVal(dyn_cast(Tuple->getOperand(3)), "MaxInternalCount", + MaxInternalCount)) return nullptr; if (!getVal(dyn_cast(Tuple->getOperand(4)), "MaxFunctionCount", MaxFunctionCount)) return nullptr; - if (!getVal(dyn_cast(Tuple->getOperand(5)), "NumBlocks", NumBlocks)) + if (!getVal(dyn_cast(Tuple->getOperand(5)), "NumCounts", NumCounts)) return nullptr; if (!getVal(dyn_cast(Tuple->getOperand(6)), "NumFunctions", NumFunctions)) return nullptr; - if (!getSummaryFromMD(dyn_cast(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(Tuple->getOperand(1)), "TotalSamples", - TotalSamples)) - return nullptr; - if (!getVal(dyn_cast(Tuple->getOperand(2)), "MaxSamplesPerLine", - MaxSamplesPerLine)) - return nullptr; - if (!getVal(dyn_cast(Tuple->getOperand(3)), "MaxFunctionCount", - MaxFunctionCount)) - return nullptr; - if (!getVal(dyn_cast(Tuple->getOperand(4)), "NumLinesWithSamples", - NumLinesWithSamples)) - return nullptr; - if (!getVal(dyn_cast(Tuple->getOperand(5)), "NumFunctions", - NumFunctions)) - return nullptr; - if (!getSummaryFromMD(dyn_cast(Tuple->getOperand(6)), Summary)) - return nullptr; - return new SampleProfileSummary(TotalSamples, MaxSamplesPerLine, - MaxFunctionCount, NumLinesWithSamples, - NumFunctions, Summary); -} - -ProfileSummary *ProfileSummary::getFromMD(Metadata *MD) { - if (!isa(MD)) - return nullptr; - MDTuple *Tuple = cast(MD); - auto &FormatMD = Tuple->getOperand(0); - if (isKeyValuePair(dyn_cast_or_null(FormatMD), "ProfileFormat", - "SampleProfile")) - return getSampleProfileSummaryFromMD(Tuple); - else if (isKeyValuePair(dyn_cast_or_null(FormatMD), "ProfileFormat", - "InstrProf")) - return getInstrProfSummaryFromMD(Tuple); - else + if (!getSummaryFromMD(dyn_cast(Tuple->getOperand(7)), Summary)) return nullptr; + return new ProfileSummary(SummaryKind, Summary, TotalCount, MaxCount, + MaxInternalCount, MaxFunctionCount, NumCounts, + NumFunctions); } Index: llvm/trunk/lib/ProfileData/InstrProfReader.cpp =================================================================== --- llvm/trunk/lib/ProfileData/InstrProfReader.cpp +++ llvm/trunk/lib/ProfileData/InstrProfReader.cpp @@ -602,13 +602,14 @@ Ent.NumBlocks); } // initialize InstrProfSummary using the SummaryData from disk. - this->Summary = llvm::make_unique( + this->Summary = llvm::make_unique( + 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: Index: llvm/trunk/lib/ProfileData/InstrProfWriter.cpp =================================================================== --- llvm/trunk/lib/ProfileData/InstrProfWriter.cpp +++ llvm/trunk/lib/ProfileData/InstrProfWriter.cpp @@ -195,17 +195,16 @@ } static void setSummary(IndexedInstrProf::Summary *TheSummary, - InstrProfSummary &PS) { + ProfileSummary &PS) { using namespace IndexedInstrProf; std::vector &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: Index: llvm/trunk/lib/ProfileData/ProfileSummaryBuilder.cpp =================================================================== --- llvm/trunk/lib/ProfileData/ProfileSummaryBuilder.cpp +++ llvm/trunk/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) { Index: llvm/trunk/lib/ProfileData/SampleProfReader.cpp =================================================================== --- llvm/trunk/lib/ProfileData/SampleProfReader.cpp +++ llvm/trunk/lib/ProfileData/SampleProfReader.cpp @@ -470,9 +470,9 @@ if (EC != sampleprof_error::success) return EC; } - Summary = llvm::make_unique( - *TotalCount, *MaxBlockCount, *MaxFunctionCount, *NumBlocks, *NumFunctions, - Entries); + Summary = llvm::make_unique( + ProfileSummary::PSK_Sample, Entries, *TotalCount, *MaxBlockCount, 0, + *MaxFunctionCount, *NumBlocks, *NumFunctions); return sampleprof_error::success; } Index: llvm/trunk/lib/ProfileData/SampleProfWriter.cpp =================================================================== --- llvm/trunk/lib/ProfileData/SampleProfWriter.cpp +++ llvm/trunk/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 &Entries = Summary->getDetailedSummary(); encodeULEB128(Entries.size(), OS); Index: llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp =================================================================== --- llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp +++ llvm/trunk/tools/llvm-profdata/llvm-profdata.cpp @@ -353,17 +353,16 @@ if (ShowCounts && TextFormat) return 0; - std::unique_ptr PS(Builder.getSummary()); + std::unique_ptr 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 Index: llvm/trunk/unittests/ProfileData/InstrProfTest.cpp =================================================================== --- llvm/trunk/unittests/ProfileData/InstrProfTest.cpp +++ llvm/trunk/unittests/ProfileData/InstrProfTest.cpp @@ -156,10 +156,11 @@ 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 &Details = IPS.getDetailedSummary(); uint32_t Cutoff = 800000; @@ -180,7 +181,7 @@ 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 @@ ASSERT_TRUE(MD); ProfileSummary *PSFromMD = ProfileSummary::getFromMD(MD); ASSERT_TRUE(PSFromMD); - ASSERT_TRUE(isa(PSFromMD)); - InstrProfSummary *IPS = cast(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 @@ ASSERT_TRUE(MD); PSFromMD = ProfileSummary::getFromMD(MD); ASSERT_TRUE(PSFromMD); - ASSERT_TRUE(isa(PSFromMD)); - IPS = cast(PSFromMD); - VerifySummary(*IPS); - delete IPS; + VerifySummary(*PSFromMD); + delete PSFromMD; } static const char callee1[] = "callee1"; Index: llvm/trunk/unittests/ProfileData/SampleProfTest.cpp =================================================================== --- llvm/trunk/unittests/ProfileData/SampleProfTest.cpp +++ llvm/trunk/unittests/ProfileData/SampleProfTest.cpp @@ -111,12 +111,13 @@ 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 @@ 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 @@ ASSERT_TRUE(MD); ProfileSummary *PS = ProfileSummary::getFromMD(MD); ASSERT_TRUE(PS); - ASSERT_TRUE(isa(PS)); - SampleProfileSummary *SPS = cast(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 @@ ASSERT_TRUE(MD); PS = ProfileSummary::getFromMD(MD); ASSERT_TRUE(PS); - ASSERT_TRUE(isa(PS)); - SPS = cast(PS); - VerifySummary(*SPS); - delete SPS; + VerifySummary(*PS); + delete PS; } };