[llvm] [SampleFDO] Read call-graph matching recovered top-level function profile (PR #101053)

Lei Wang via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 16 17:03:13 PDT 2024


================
@@ -782,6 +782,25 @@ bool SampleProfileMatcher::functionMatchesProfileHelper(
   float Similarity = 0.0;
 
   const auto *FSFlattened = getFlattenedSamplesFor(ProfFunc);
+  // With extbinary profile format, initial profile loading only reads profile
+  // based on current function names in the module.
+  // However, if a function is renamed, sample loader fails to load its original
+  // profile(which has a different name), we will miss this case. To address
+  // this, we load the top-level profile candidate explicitly for the matching.
+  if (!FSFlattened) {
+    DenseSet<StringRef> TopLevelFunc({ProfFunc.stringRef()});
+    SampleProfileMap TopLevelProfile;
+    Reader.read(TopLevelFunc, TopLevelProfile);
----------------
wlei-llvm wrote:

This is different to the one in `UpdateWithSalvagedProfiles`. We use a different profile map for the matching, `FlattenedProfiles`. so here the output map is the `FlattenedProfiles`, not the sample reader's internal `Profiles`.

https://github.com/llvm/llvm-project/pull/101053


More information about the llvm-commits mailing list