[llvm] [SampleFDO] Read call-graph matching recovered top-level function profile (PR #101053)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 17:34:40 PDT 2024
================
@@ -782,6 +782,26 @@ bool SampleProfileMatcher::functionMatchesProfileHelper(
float Similarity = 0.0;
const auto *FSFlattened = getFlattenedSamplesFor(ProfFunc);
+ // Check if the function is top-level function. For extended profile format,
+ // if a function profile is unused and it's top-level, even if the profile is
+ // matched, it's not found in the profile. This is because sample reader only
+ // read the used profile at the beginning, we need to read the profile
+ // on-demand. Also save it into the FlattenedProfiles for future look-up.
+ if (!FSFlattened) {
+ DenseSet<StringRef> TopLevelFunc;
+ TopLevelFunc.insert(ProfFunc.stringRef());
+ SampleProfileMap TopLevelProfile;
+ Reader.readOnDemand(TopLevelFunc, TopLevelProfile);
----------------
WenleiHe wrote:
How about we add a switch to on/off this feature? Just in case this (loading profile for matched functions) overall becomes expensive.
https://github.com/llvm/llvm-project/pull/101053
More information about the llvm-commits
mailing list