[llvm] [SampleProfileMatcher] Sample profile duplication to avoid stale CFG profile matching conflicts (PR #202460)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 3 12:45:08 PDT 2026
================
@@ -362,6 +362,67 @@ void SampleProfileMatcher::runStaleProfileMatching(
longestCommonSequence(FilteredIRAnchorsList, FilteredProfileAnchorList,
RunCGMatching /* Match unused functions */);
+ // Scan through the matched anchors to make sure functions and profiles are
+ // 1:1 mapped. If the profile has already been mapped to another function
+ // during previous fuzzy matching, create a new profile with the same sample
+ // counts and assumed to be pre-inlined.
+ for (const auto &IR : IRAnchors) {
----------------
HighW4y2H3ll wrote:
ah, sorry, the comment should be "assumed to be **not** pre-inlined". The new profile just a direct copy of its flattened profile as a top-level function. This new profile will run through the stale profile matching again to map it's IR to the new profile.
We probably don't need to worry about the *nested* LCS matching that checks callees' similarity? It won't update `FuncToProfileNameMap` at all so it won't create extra 1:N mappings?
https://github.com/llvm/llvm-project/blob/16a6b516d7b72be6d1cd480febb2c1ebf2aa78c2/llvm/lib/Transforms/IPO/SampleProfileMatcher.cpp#L1009-L1011
https://github.com/llvm/llvm-project/pull/202460
More information about the llvm-commits
mailing list