diff options
| author | Wei Mi <wmi@google.com> | 2019-09-23 22:11:35 +0000 |
|---|---|---|
| committer | Wei Mi <wmi@google.com> | 2019-09-23 22:11:35 +0000 |
| commit | 22fd88530b11af92e1c2658c755d3915538a844d (patch) | |
| tree | 4ac6500419878ada1ffd254d8c369d7b57da616e /llvm/lib/Transforms | |
| parent | 28b38c277a2941e9e891b2db30652cfd962f070b (diff) | |
| download | bcm5719-llvm-22fd88530b11af92e1c2658c755d3915538a844d.tar.gz bcm5719-llvm-22fd88530b11af92e1c2658c755d3915538a844d.zip | |
[SampleFDO] Treat names in profile as not cold only when profile symbol list
is available
In rL372232, we treated names showing up in profile as not cold when
profile-sample-accurate is enabled. This caused 70k size regression in
Chrome/Android. The patch put a guard and only enable the change when
profile symbol list is available, i.e., keep the old behavior when profile
symbol list is not available.
Differential Revision: https://reviews.llvm.org/D67931
llvm-svn: 372665
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/IPO/SampleProfile.cpp | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp index 9c9d851a470..b647818345d 100644 --- a/llvm/lib/Transforms/IPO/SampleProfile.cpp +++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp @@ -1770,27 +1770,32 @@ bool SampleProfileLoader::runOnFunction(Function &F, ModuleAnalysisManager *AM) if (ProfSampleAccEnabled) { // PSL -- profile symbol list include all the symbols in sampled binary. // It is used to prevent new functions to be treated as cold. - // If ProfileSampleAccurate is true or F has profile-sample-accurate - // attribute, and if there is no profile symbol list read in, initialize - // all the function entry counts to 0; if there is profile symbol list, only - // initialize the entry count to 0 when current function is in the list. - if (!PSL || PSL->contains(F.getName())) + if (PSL) { + // Profile symbol list is available, initialize the entry count to 0 + // only for functions in the list. + if (PSL->contains(F.getName())) + initialEntryCount = 0; + + // When ProfileSampleAccurate is true, function without sample will be + // regarded as cold. To minimize the potential negative performance + // impact it could have, we want to be a little conservative here + // saying if a function shows up in the profile, no matter as outline + // function, inline instance or call targets, treat the function as not + // being cold. This will handle the cases such as most callsites of a + // function are inlined in sampled binary but not inlined in current + // build (because of source code drift, imprecise debug information, or + // the callsites are all cold individually but not cold + // accumulatively...), so the outline function showing up as cold in + // sampled binary will actually not be cold after current build. + StringRef CanonName = FunctionSamples::getCanonicalFnName(F); + if (NamesInProfile.count(CanonName)) + initialEntryCount = -1; + } else { + // If there is no profile symbol list available, initialize all the + // function entry counts to 0. It means all the functions without + // profile will be regarded as cold. initialEntryCount = 0; - - // When ProfileSampleAccurate is true, function without sample will be - // regarded as cold. To minimize the potential negative performance - // impact it could have, we want to be a little conservative here - // saying if a function shows up in the profile, no matter as outline - // function, inline instance or call targets, treat the function as not - // being cold. This will handle the cases such as most callsites of a - // function are inlined in sampled binary but not inlined in current - // build (because of source code drift, imprecise debug information, or - // the callsites are all cold individually but not cold accumulatively...), - // so the outline function showing up as cold in sampled binary will - // actually not be cold after current build. - StringRef CanonName = FunctionSamples::getCanonicalFnName(F); - if (NamesInProfile.count(CanonName)) - initialEntryCount = -1; + } } F.setEntryCount(ProfileCount(initialEntryCount, Function::PCT_Real)); |

