================
@@ -266,6 +305,69 @@ class StaleMatcher {
     }
     return BestBlock;
   }
+
+  /// Matches a profile block with an binary block based on pseudo probes.
+  /// Returns the best matching block (or nullptr) and whether the match is
+  /// unambiguous.
+  std::pair<const FlowBlock *, bool> matchWithPseudoProbes(
+      const ArrayRef<yaml::bolt::PseudoProbeInfo> BlockPseudoProbes,
+      const ArrayRef<yaml::bolt::InlineTreeNode> InlineTree) const {
+    if (!opts::StaleMatchingWithPseudoProbes)
+      return {nullptr, false};
+
+    DenseMap<const FlowBlock *, uint32_t> FlowBlockMatchCount;
+
+    auto match = [&](uint32_t NodeId, uint64_t ProbeId) -> const FlowBlock * {
+      const MCDecodedPseudoProbeInlineTree *Node =
+          InlineTreeNodeMap.getInlineTreeNode(NodeId);
+      if (!Node)
+        return nullptr;
+      const MCDecodedPseudoProbe *BinaryProbe = nullptr;
+      for (const MCDecodedPseudoProbe &Probe : Node->getProbes()) {
+        if (Probe.getIndex() != ProbeId)
----------------
wlei-llvm wrote:

nit:  just for the readability, is it possible to add the `Binary` or `Profile` 
prefix to the variable names, especially when they are used closely. Same to 
other places like `Node/Tree/Probe/...` but only when you think it's not too 
verbose:)

https://github.com/llvm/llvm-project/pull/99891
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to