[llvm] [SampleFDO] Stale profile call-graph matching (PR #95135)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 16 12:09:50 PDT 2024
================
@@ -127,8 +147,37 @@ void SampleProfileMatcher::findProfileAnchors(const FunctionSamples &FS,
}
}
-LocToLocMap SampleProfileMatcher::longestCommonSequence(
- const AnchorList &AnchorList1, const AnchorList &AnchorList2) const {
+bool SampleProfileMatcher::functionMatchesProfile(
+ const FunctionId &IRFuncName, const FunctionId &ProfileFuncName,
+ bool FindMatchedProfileOnly) {
+ if (IRFuncName == ProfileFuncName)
+ return true;
+ if (!SalvageUnusedProfile)
+ return false;
+ // If IR function and profile function don't appear on either side, try
+ // matching the profile function.
+
+ // Check whether IR function appears in profile.
+ auto R = NewIRFunctions.find(IRFuncName);
+ if (R == NewIRFunctions.end() || !R->second)
+ return false;
+ Function &IRFunc = *R->second;
+ assert(FunctionId(IRFunc.getName()) != ProfileFuncName &&
+ "IR function should be different from profile function to match");
+
+ // Check whether profile function appears in IR.
+ auto F = SymbolMap->find(ProfileFuncName);
+ if (F != SymbolMap->end())
+ return false;
----------------
WenleiHe wrote:
So this is because if the profile already matches a function with the same name, we don't want it to be matched to another function? If so, I understand the intention, but a match is match. Perhaps the logic can be split into `isProfileUnused`(hence cannot be matched to another function) + `functionMatchesProfile`?
https://github.com/llvm/llvm-project/pull/95135
More information about the llvm-commits
mailing list