================ @@ -266,6 +287,47 @@ class StaleMatcher { } return BestBlock; } + // Uses pseudo probe information to attach the profile to the appropriate + // block. + const FlowBlock *matchWithPseudoProbes( + const std::vector<yaml::bolt::PseudoProbeInfo> &PseudoProbes) const { + // Searches for the pseudo probe attached to the matched function's block, + // ignoring pseudo probes attached to function calls and inlined functions' + // blocks. + std::vector<const yaml::bolt::PseudoProbeInfo *> BlockPseudoProbes; + for (const auto &PseudoProbe : PseudoProbes) { + // Ensures that pseudo probe information belongs to the appropriate + // function and not an inlined function. + if (PseudoProbe.GUID != YamlBFGUID) + continue; + // Skips pseudo probes attached to function calls. + if (PseudoProbe.Type != static_cast<uint8_t>(PseudoProbeType::Block)) + continue; + + BlockPseudoProbes.push_back(&PseudoProbe); + } + + // Returns nullptr if there is not a 1:1 mapping of the yaml block pseudo + // probe and binary pseudo probe. + if (BlockPseudoProbes.size() == 0 || BlockPseudoProbes.size() > 1) + return nullptr; + + uint64_t Index = BlockPseudoProbes[0]->Index; + assert(Index <= Blocks.size() && "Invalid pseudo probe index"); + + auto It = IndexToBinaryPseudoProbes.find(Index); + assert(It != IndexToBinaryPseudoProbes.end() && + "All blocks should have a pseudo probe"); ---------------- aaupov wrote:
This assert should become a check as it's possible to have blocks without probes 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