diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/libs/llvm12/lib/ProfileData/ProfileSummaryBuilder.cpp | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/libs/llvm12/lib/ProfileData/ProfileSummaryBuilder.cpp')
-rw-r--r-- | contrib/libs/llvm12/lib/ProfileData/ProfileSummaryBuilder.cpp | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/contrib/libs/llvm12/lib/ProfileData/ProfileSummaryBuilder.cpp b/contrib/libs/llvm12/lib/ProfileData/ProfileSummaryBuilder.cpp index 0e03aa5017..0f1e6d1a65 100644 --- a/contrib/libs/llvm12/lib/ProfileData/ProfileSummaryBuilder.cpp +++ b/contrib/libs/llvm12/lib/ProfileData/ProfileSummaryBuilder.cpp @@ -18,14 +18,14 @@ #include "llvm/ProfileData/ProfileCommon.h" #include "llvm/ProfileData/SampleProf.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; -cl::opt<bool> UseContextLessSummary( - "profile-summary-contextless", cl::Hidden, cl::init(false), cl::ZeroOrMore, - cl::desc("Merge context profiles before calculating thresholds.")); - +cl::opt<bool> UseContextLessSummary( + "profile-summary-contextless", cl::Hidden, cl::init(false), cl::ZeroOrMore, + cl::desc("Merge context profiles before calculating thresholds.")); + // A set of cutoff values. Each value, when divided by ProfileSummary::Scale // (which is 1000000) is a desired percentile of total counts. static const uint32_t DefaultCutoffsData[] = { @@ -116,35 +116,35 @@ std::unique_ptr<ProfileSummary> SampleProfileSummaryBuilder::getSummary() { MaxFunctionCount, NumCounts, NumFunctions); } -std::unique_ptr<ProfileSummary> -SampleProfileSummaryBuilder::computeSummaryForProfiles( - const StringMap<sampleprof::FunctionSamples> &Profiles) { - assert(NumFunctions == 0 && - "This can only be called on an empty summary builder"); - StringMap<sampleprof::FunctionSamples> ContextLessProfiles; - const StringMap<sampleprof::FunctionSamples> *ProfilesToUse = &Profiles; - // For CSSPGO, context-sensitive profile effectively split a function profile - // into many copies each representing the CFG profile of a particular calling - // context. That makes the count distribution looks more flat as we now have - // more function profiles each with lower counts, which in turn leads to lower - // hot thresholds. To compensate for that, by defauly we merge context - // profiles before coumputing profile summary. - if (UseContextLessSummary || (sampleprof::FunctionSamples::ProfileIsCS && - !UseContextLessSummary.getNumOccurrences())) { - for (const auto &I : Profiles) { - ContextLessProfiles[I.second.getName()].merge(I.second); - } - ProfilesToUse = &ContextLessProfiles; - } - - for (const auto &I : *ProfilesToUse) { - const sampleprof::FunctionSamples &Profile = I.second; - addRecord(Profile); - } - - return getSummary(); -} - +std::unique_ptr<ProfileSummary> +SampleProfileSummaryBuilder::computeSummaryForProfiles( + const StringMap<sampleprof::FunctionSamples> &Profiles) { + assert(NumFunctions == 0 && + "This can only be called on an empty summary builder"); + StringMap<sampleprof::FunctionSamples> ContextLessProfiles; + const StringMap<sampleprof::FunctionSamples> *ProfilesToUse = &Profiles; + // For CSSPGO, context-sensitive profile effectively split a function profile + // into many copies each representing the CFG profile of a particular calling + // context. That makes the count distribution looks more flat as we now have + // more function profiles each with lower counts, which in turn leads to lower + // hot thresholds. To compensate for that, by defauly we merge context + // profiles before coumputing profile summary. + if (UseContextLessSummary || (sampleprof::FunctionSamples::ProfileIsCS && + !UseContextLessSummary.getNumOccurrences())) { + for (const auto &I : Profiles) { + ContextLessProfiles[I.second.getName()].merge(I.second); + } + ProfilesToUse = &ContextLessProfiles; + } + + for (const auto &I : *ProfilesToUse) { + const sampleprof::FunctionSamples &Profile = I.second; + addRecord(Profile); + } + + return getSummary(); +} + std::unique_ptr<ProfileSummary> InstrProfSummaryBuilder::getSummary() { computeDetailedSummary(); return std::make_unique<ProfileSummary>( @@ -153,22 +153,22 @@ std::unique_ptr<ProfileSummary> InstrProfSummaryBuilder::getSummary() { } void InstrProfSummaryBuilder::addEntryCount(uint64_t Count) { - NumFunctions++; - - // Skip invalid count. - if (Count == (uint64_t)-1) - return; - + NumFunctions++; + + // Skip invalid count. + if (Count == (uint64_t)-1) + return; + addCount(Count); if (Count > MaxFunctionCount) MaxFunctionCount = Count; } void InstrProfSummaryBuilder::addInternalCount(uint64_t Count) { - // Skip invalid count. - if (Count == (uint64_t)-1) - return; - + // Skip invalid count. + if (Count == (uint64_t)-1) + return; + addCount(Count); if (Count > MaxInternalBlockCount) MaxInternalBlockCount = Count; |