[llvm] [SampleFDO] Improve stale profile matching by diff algorithm (PR #87375)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 8 23:06:56 PDT 2024


================
@@ -84,27 +85,28 @@ void SampleProfileMatcher::findIRAnchors(
         } else {
           LineLocation Callsite = FunctionSamples::getCallSiteIdentifier(DIL);
           StringRef CalleeName = GetCanonicalCalleeName(dyn_cast<CallBase>(&I));
-          IRAnchors.emplace(Callsite, CalleeName);
+          IRAnchors.emplace(Callsite, FunctionId(CalleeName));
         }
       }
     }
   }
 }
 
-void SampleProfileMatcher::findProfileAnchors(
-    const FunctionSamples &FS,
-    std::map<LineLocation, std::unordered_set<FunctionId>> &ProfileAnchors) {
+void SampleProfileMatcher::findProfileAnchors(const FunctionSamples &FS,
+                                              AnchorMap &ProfileAnchors) {
   auto isInvalidLineOffset = [](uint32_t LineOffset) {
     return LineOffset & 0x8000;
   };
 
+  std::map<LineLocation, std::unordered_set<FunctionId>> ProfileCallsites;
----------------
WenleiHe wrote:

Can we avoid the intermediate `ProfileCallsites`? i.e. how about we just populate `ProfileAnchors` directly? When we encounter a second callee for an anchor location, change the callee to `UnknownIndirectCallee` on the fly.

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


More information about the llvm-commits mailing list