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

Lei Wang via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 19 11:38:21 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:

Sounds good. It's a little bit tricky, there could be more places to use the `FlattenedProfiles`(the profiles for the matching), then anywhere it used, we also need to original samples reader.  (I was thinking to rename `FlattenedProfiles` and use it so that we only have one container.). Right now there is only one more place, just updated that. 

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


More information about the llvm-commits mailing list