[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:40 PDT 2024
================
@@ -96,6 +101,42 @@ class YAMLProfileReader : public ProfileReaderBase {
YamlBFAdjacencyMap;
};
+ // A class for matching inline tree nodes between profile and binary.
+ class InlineTreeNodeMapTy {
+ DenseMap<uint32_t, const MCDecodedPseudoProbeInlineTree *> Map;
+
+ void mapInlineTreeNode(uint32_t ProfileNode,
+ const MCDecodedPseudoProbeInlineTree *BinaryNode) {
+ auto Res = Map.try_emplace(ProfileNode, BinaryNode);
+ assert(Res.second &&
+ "Duplicate mapping from profile node index to binary inline tree");
+ (void)Res;
+ }
+
+ public:
+ /// Returns matched InlineTree * for a given profile inline_tree_id.
+ const MCDecodedPseudoProbeInlineTree *
+ getInlineTreeNode(uint32_t ProfileInlineTreeNodeId) const {
+ auto It = Map.find(ProfileInlineTreeNodeId);
+ if (It == Map.end())
+ return nullptr;
+ return It->second;
+ }
+
+ // Match up YAML inline tree with binary inline tree.
+ // \p GetRootCallback is invoked for matching up the first YAML inline tree
+ // node and has the following signature:
+ // const MCDecodedPseudoProbeInlineTree *GetRootCallback(uint64_t RootGUID)
+ void matchInlineTrees(
----------------
wlei-llvm wrote:
Maybe rename to `readAndMatchInlineTrees` or `buildAndMatchingInlinTrees`? I see a big part of the code is to read and build the trees from yaml. Or maybe split it into two functions?
https://github.com/llvm/llvm-project/pull/99891
More information about the llvm-branch-commits
mailing list