================
@@ -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
_______________________________________________
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