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

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 17 07:28:10 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);
----------------
WenleiHe wrote:

We can still make the API simpler for reader - we can always load into reader's profile map, and then retriever it by name for downstream use. Reader can serve as a cache too.

OTOH, the profile from reader isn't guaranteed to be flattened, why do we put it directly into flattened profile map anyways? 



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


More information about the llvm-commits mailing list