[llvm] [CSSPGO] Compute and report profile matching recovered callsites and samples (PR #79090)

Lei Wang via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 15 10:53:13 PST 2024


================
@@ -444,15 +444,36 @@ class SampleProfileMatcher {
   // the profile.
   StringMap<LocToLocMap> FuncMappings;
 
-  // Profile mismatching statstics.
+  // Match state for an anchor/callsite.
+  enum class MatchState {
+    Matched = 0,
+    Mismatched = 1,
+    // Stay Matched after profile matching.
+    StayMatched = 2,
+    // Recovered from Mismatched after profile matching.
+    Recovered = 3,
+    Unknown = 32,
+  };
+
+  // For each function, store every callsite and its matching state into this
+  // map, of which each entry is a pair of callsite location and MatchState.
+  // This is used for profile staleness computation and report.
+  StringMap<std::unordered_map<LineLocation, MatchState, LineLocationHash>>
----------------
wlei-llvm wrote:

> note that StringMap keeps a copy of every string key.

I think one optimization is we can release this data after the matching is done, we don't use those data for the later sample inlining or loading stuffs, similar to the `StringMap<LocToLocMap> FuncMappings;`.

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


More information about the llvm-commits mailing list