From 172ff13310aecd0e194eabcbc4a910888682815b Mon Sep 17 00:00:00 2001 From: Taewook Oh Date: Wed, 3 Apr 2019 19:54:43 +0000 Subject: [PATCH] [ProfileSummary] Count callsite samples when computing total samples. Summary: Currently ProfileSummaryBuilder doesn't count into callsite samples when computing total samples. Considering that ProfileSummaryInfo is used to checked the hotness of not only body samples but also callsite samples (from SampleProfileLoader), I think the callsite sample counts should be considered when computing total samples. Reviewers: eraman, danielcdh, wmi Subscribers: hiraditya, jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59835 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357627 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ProfileData/ProfileCommon.h | 3 ++- lib/ProfileData/ProfileSummaryBuilder.cpp | 13 +++++++++---- .../Inputs/inline.compactbinary.afdo | Bin 184 -> 185 bytes .../SampleProfile/Inputs/summary.prof | 5 +++++ .../SampleProfile/compact-binary-profile.ll | 2 +- test/Transforms/SampleProfile/summary.ll | 13 ++++++++++++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/include/llvm/ProfileData/ProfileCommon.h b/include/llvm/ProfileData/ProfileCommon.h index b52f8864320..f98a34387fd 100644 --- a/include/llvm/ProfileData/ProfileCommon.h +++ b/include/llvm/ProfileData/ProfileCommon.h @@ -83,7 +83,8 @@ public: SampleProfileSummaryBuilder(std::vector Cutoffs) : ProfileSummaryBuilder(std::move(Cutoffs)) {} - void addRecord(const sampleprof::FunctionSamples &FS); + void addRecord(const sampleprof::FunctionSamples &FS, + bool isCallsiteSample = false); std::unique_ptr getSummary(); }; diff --git a/lib/ProfileData/ProfileSummaryBuilder.cpp b/lib/ProfileData/ProfileSummaryBuilder.cpp index 35ac5b90cd1..4d5b0093574 100644 --- a/lib/ProfileData/ProfileSummaryBuilder.cpp +++ b/lib/ProfileData/ProfileSummaryBuilder.cpp @@ -44,12 +44,17 @@ void InstrProfSummaryBuilder::addRecord(const InstrProfRecord &R) { // To compute the detailed summary, we consider each line containing samples as // equivalent to a block with a count in the instrumented profile. void SampleProfileSummaryBuilder::addRecord( - const sampleprof::FunctionSamples &FS) { - NumFunctions++; - if (FS.getHeadSamples() > MaxFunctionCount) - MaxFunctionCount = FS.getHeadSamples(); + const sampleprof::FunctionSamples &FS, bool isCallsiteSample) { + if (!isCallsiteSample) { + NumFunctions++; + if (FS.getHeadSamples() > MaxFunctionCount) + MaxFunctionCount = FS.getHeadSamples(); + } for (const auto &I : FS.getBodySamples()) addCount(I.second.getSamples()); + for (const auto &I : FS.getCallsiteSamples()) + for (const auto &CS : I.second) + addRecord(CS.second, true); } // The argument to this method is a vector of cutoff percentages and the return diff --git a/test/Transforms/SampleProfile/Inputs/inline.compactbinary.afdo b/test/Transforms/SampleProfile/Inputs/inline.compactbinary.afdo index 6271b3609e90c2e33b9e98dfc9feb31e067ce5c4..c9fde769982810d20a8b9f3173311c0d7fbeccaf 100644 GIT binary patch delta 156 zcmdnNxRX(^>B)tSUrtV05u85vBI8DF2G)rJV&45)ObuHlfaHQha`QD=51dy4k`L}^ z0m+6}20(JbcQYXQ;jbl-+_23CNZ$AZBJVWY0?BPHAaXyLoLDGgyp;h87&kxWWnuzZ g!_3gH#lXnS$nZp$nSo)xCIcggU;+^gjEsGZ0Ic#eG5`Po literal 184 zcmZpAa$)0_lT%g%rymI2sLjB{C@{fqqc-D$UN#_kU=|OMe6U;yNH%Ph0Er)x1Bstk z>DOX