[llvm-branch-commits] [llvm] [BOLT] Match blocks with pseudo probes (PR #99891)
Lei Wang via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Sep 18 11:28:39 PDT 2024
================
@@ -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
More information about the llvm-branch-commits
mailing list