[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


================
@@ -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.
----------------
wlei-llvm wrote:

Could you add more comments to explain the output of this function and how it will be used for the matching later?

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


More information about the llvm-branch-commits mailing list