[llvm] [SampleFDO] Stale profile call-graph matching (PR #95135)
Lei Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 24 15:59:13 PDT 2024
================
@@ -127,8 +143,43 @@ void SampleProfileMatcher::findProfileAnchors(const FunctionSamples &FS,
}
}
-LocToLocMap SampleProfileMatcher::longestCommonSequence(
- const AnchorList &AnchorList1, const AnchorList &AnchorList2) const {
+Function *
+SampleProfileMatcher::findIfFunctionIsNew(const FunctionId &IRFuncName) {
+ auto R = NewIRFunctions.find(IRFuncName);
+ if (R == NewIRFunctions.end())
+ return nullptr;
+ return R->second;
+}
+
+bool SampleProfileMatcher::isProfileUnused(const FunctionId &ProfileFuncName) {
+ auto F = SymbolMap->find(ProfileFuncName);
+ return F == SymbolMap->end();
+}
+
+bool SampleProfileMatcher::functionMatchesProfile(
+ const FunctionId &IRFuncName, const FunctionId &ProfileFuncName,
+ bool FindMatchedProfileOnly) {
+ if (IRFuncName == ProfileFuncName)
+ return true;
+ if (!SalvageUnusedProfile)
+ return false;
+
+ // If IR function doesn't have profile and the profile is unused, try
+ // matching them.
+ Function *IRFunc = findIfFunctionIsNew(IRFuncName);
----------------
wlei-llvm wrote:
Sounds good. Will change
`findNewIRFunctions ` -> `findFunctionsWithoutProfile`
`findIfFunctionIsNew ` -> `functionHasProfile`
Thanks for the suggestion!
https://github.com/llvm/llvm-project/pull/95135
More information about the llvm-commits
mailing list