diff options
| author | Easwaran Raman <eraman@google.com> | 2019-01-09 20:10:27 +0000 |
|---|---|---|
| committer | Easwaran Raman <eraman@google.com> | 2019-01-09 20:10:27 +0000 |
| commit | b45994b843fdf6d150a188f3ad1ffce89794a31e (patch) | |
| tree | 39ee78b157d7811901ffe6827ba4d3ea087df5e8 /llvm/lib/LTO | |
| parent | 39287e759f9a2a53050d70b9b34b4be14f09d1e3 (diff) | |
| download | bcm5719-llvm-b45994b843fdf6d150a188f3ad1ffce89794a31e.tar.gz bcm5719-llvm-b45994b843fdf6d150a188f3ad1ffce89794a31e.zip | |
Refactor synthetic profile count computation. NFC.
Summary:
Instead of using two separate callbacks to return the entry count and the
relative block frequency, use a single callback to return callsite
count. This would allow better supporting hybrid mode in the future as
the count of callsite need not always be derived from entry count (as in
sample PGO).
Reviewers: davidxl
Subscribers: mehdi_amini, steven_wu, dexonsmith, dang, llvm-commits
Differential Revision: https://reviews.llvm.org/D56464
llvm-svn: 350755
Diffstat (limited to 'llvm/lib/LTO')
| -rw-r--r-- | llvm/lib/LTO/SummaryBasedOptimizations.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/LTO/SummaryBasedOptimizations.cpp b/llvm/lib/LTO/SummaryBasedOptimizations.cpp index 8b1abb78462..bcdd984daa5 100644 --- a/llvm/lib/LTO/SummaryBasedOptimizations.cpp +++ b/llvm/lib/LTO/SummaryBasedOptimizations.cpp @@ -60,21 +60,27 @@ void llvm::computeSyntheticCounts(ModuleSummaryIndex &Index) { return UINT64_C(0); } }; - auto AddToEntryCount = [](ValueInfo V, uint64_t New) { + auto AddToEntryCount = [](ValueInfo V, Scaled64 New) { if (!V.getSummaryList().size()) return; for (auto &GVS : V.getSummaryList()) { auto S = GVS.get()->getBaseObject(); auto *F = cast<FunctionSummary>(S); - F->setEntryCount(SaturatingAdd(F->entryCount(), New)); + F->setEntryCount( + SaturatingAdd(F->entryCount(), New.template toInt<uint64_t>())); } }; + auto GetProfileCount = [&](ValueInfo V, FunctionSummary::EdgeTy &Edge) { + auto RelFreq = GetCallSiteRelFreq(Edge); + Scaled64 EC(GetEntryCount(V), 0); + return RelFreq * EC; + }; // After initializing the counts in initializeCounts above, the counts have to // be propagated across the combined callgraph. // SyntheticCountsUtils::propagate takes care of this propagation on any // callgraph that specialized GraphTraits. - SyntheticCountsUtils<ModuleSummaryIndex *>::propagate( - &Index, GetCallSiteRelFreq, GetEntryCount, AddToEntryCount); + SyntheticCountsUtils<ModuleSummaryIndex *>::propagate(&Index, GetProfileCount, + AddToEntryCount); Index.setHasSyntheticEntryCounts(); } |

