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

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 20:50:49 PDT 2024


================
@@ -122,15 +122,153 @@ void SampleProfileMatcher::findProfileAnchors(
   }
 }
 
+MyersDiff::DiffResult
+MyersDiff::longestCommonSequence(const std::vector<Anchor> &A,
+                                 const std::vector<Anchor> &B) const {
+  int32_t N = A.size(), M = B.size(), Max = N + M;
+  auto Index = [&](int32_t I) { return I + Max; };
+
+  DiffResult Diff;
+  if (Max == 0)
+    return Diff;
+
+  // Backtrack the SES result.
+  auto Backtrack = [&](const std::vector<std::vector<int32_t>> &Trace,
----------------
WenleiHe wrote:

nit: why take `Trace` as parameter but capture `Diff` instead of taking `Diff` as parameter too? Perhaps all pass through reference parameter to be consistent? 

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


More information about the llvm-commits mailing list