[llvm] f97eb1d - [NFC][Sample PGO] Avoid non-const accessor for CallsiteSamples
Wenlei He via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 28 13:44:06 PDT 2023
Author: Wenlei He
Date: 2023-06-28T13:43:30-07:00
New Revision: f97eb1dd8f08e6cb37584bb3bb3d54dc320cff19
URL: https://github.com/llvm/llvm-project/commit/f97eb1dd8f08e6cb37584bb3bb3d54dc320cff19
DIFF: https://github.com/llvm/llvm-project/commit/f97eb1dd8f08e6cb37584bb3bb3d54dc320cff19.diff
LOG: [NFC][Sample PGO] Avoid non-const accessor for CallsiteSamples
Exposing a non-const accessor for clearing CallsiteSamples during flattening is a big of an overkill. Replace the non-const accessor with removeAllCallsiteSamples.
Differential Revision: https://reviews.llvm.org/D153995
Added:
Modified:
llvm/include/llvm/ProfileData/SampleProf.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/ProfileData/SampleProf.h b/llvm/include/llvm/ProfileData/SampleProf.h
index f92b993bded59..12cc1f2fd002b 100644
--- a/llvm/include/llvm/ProfileData/SampleProf.h
+++ b/llvm/include/llvm/ProfileData/SampleProf.h
@@ -800,6 +800,12 @@ class FunctionSamples {
return Count;
}
+ // Remove all call site samples for inlinees. This is needed when flattening
+ // a nested profile.
+ void removeAllCallsiteSamples() {
+ CallsiteSamples.clear();
+ }
+
// Accumulate all call target samples to update the body samples.
void updateCallsiteSamples() {
for (auto &I : BodySamples) {
@@ -957,8 +963,6 @@ class FunctionSamples {
return CallsiteSamples;
}
- CallsiteSampleMap &getCallsiteSamples() { return CallsiteSamples; }
-
/// Return the maximum of sample counts in a function body. When SkipCallSite
/// is false, which is the default, the return count includes samples in the
/// inlined functions. When SkipCallSite is true, the return count only
@@ -1384,9 +1388,9 @@ class ProfileConverter {
auto Ret = OutputProfiles.try_emplace(Context, FS);
FunctionSamples &Profile = Ret.first->second;
if (Ret.second) {
- // When it's the copy of the old profile, just clear all the inlinees'
- // samples.
- Profile.getCallsiteSamples().clear();
+ // Clear nested inlinees' samples for the flattened copy. These inlinees
+ // will have their own top-level entries after flattening.
+ Profile.removeAllCallsiteSamples();
// We recompute TotalSamples later, so here set to zero.
Profile.setTotalSamples(0);
} else {
More information about the llvm-commits
mailing list