[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
Mon Oct 28 22:33:37 PDT 2024
================
@@ -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
More information about the llvm-branch-commits
mailing list