================ @@ -628,9 +618,75 @@ void YAMLProfileReader::InlineTreeNodeMapTy::matchInlineTrees( } } } - if (Cur && Decoder.getFuncDescForGUID(GUID)->FuncHash == Hash) + // Don't match nodes if the profile is stale (mismatching binary FuncHash + // and YAML Hash) + if (Cur && Decoder.getFuncDescForGUID(Cur->Guid)->FuncHash == Hash) mapInlineTreeNode(InlineTreeNodeId, Cur); } + return Map.size(); +} + +// Decode index deltas and indirection through \p YamlPD. Return modified copy +// of \p YamlInlineTree with populated decoded fields (GUID, Hash, ParentIndex). +static std::vector<yaml::bolt::InlineTreeNode> +decodeYamlInlineTree(const yaml::bolt::ProfilePseudoProbeDesc &YamlPD, + std::vector<yaml::bolt::InlineTreeNode> YamlInlineTree) { + uint32_t ParentId = 0; + uint32_t PrevGUIDIdx = 0; + for (yaml::bolt::InlineTreeNode &InlineTreeNode : YamlInlineTree) { + uint32_t GUIDIdx = InlineTreeNode.GUIDIndex; + if (GUIDIdx != UINT32_MAX) + PrevGUIDIdx = GUIDIdx; + else + GUIDIdx = PrevGUIDIdx; + uint32_t HashIdx = YamlPD.GUIDHashIdx[GUIDIdx]; + ParentId += InlineTreeNode.ParentIndexDelta; + InlineTreeNode.GUID = YamlPD.GUID[GUIDIdx]; + InlineTreeNode.Hash = YamlPD.Hash[HashIdx]; + InlineTreeNode.ParentIndexDelta = ParentId; + } + return YamlInlineTree; +} + +size_t YAMLProfileReader::matchWithPseudoProbes(BinaryContext &BC) { + const MCPseudoProbeDecoder *Decoder = BC.getPseudoProbeDecoder(); + const yaml::bolt::ProfilePseudoProbeDesc &YamlPD = YamlBP.PseudoProbeDesc; + + // Set existing BF->YamlBF match into ProbeMatchSpecs for (local) probe + // matching. + if (opts::StaleMatchingWithPseudoProbes) { ---------------- wlei-llvm wrote:
nit: early return(`if (!opts::StaleMatchingWithPseudoProbes) ...`) to save indentation. 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