================ @@ -446,6 +503,56 @@ size_t YAMLProfileReader::matchWithLTOCommonName() { return MatchedWithLTOCommonName; } +size_t YAMLProfileReader::matchWithCallGraph(BinaryContext &BC) { + if (!opts::MatchWithCallGraph) + return 0; + + size_t MatchedWithCallGraph = 0; + CGMatcher.computeBFNeighborHashes(BC); + CGMatcher.constructYAMLFCG(YamlBP, IdToYamLBF); + + // Matches YAMLBF to BFs with neighbor hashes. + for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions) { + if (YamlBF.Used) + continue; + auto It = CGMatcher.YamlBFAdjacencyMap.find(&YamlBF); + if (It == CGMatcher.YamlBFAdjacencyMap.end()) + continue; + // Computes profiled function's neighbor hash. + std::set<yaml::bolt::BinaryFunctionProfile *> &AdjacentFunctions = + It->second; + std::string AdjacentFunctionHashStr; + for (auto &AdjacentFunction : AdjacentFunctions) { + AdjacentFunctionHashStr += AdjacentFunction->Name; + } + uint64_t Hash = std::hash<std::string>{}(AdjacentFunctionHashStr); + auto NeighborHashToBFsIt = CGMatcher.NeighborHashToBFs.find(Hash); + if (NeighborHashToBFsIt == CGMatcher.NeighborHashToBFs.end()) + continue; + // Finds the binary function with the closest block size to the profiled ---------------- aaupov wrote:
Two concerns here: - worst-case runtime - please check the size of the largest NeighborHashToBFs bucket in a large binary - closest block count may not find the best match, we'll need to look at a couple of examples from real binary+stale profile to find out a good proxy. https://github.com/llvm/llvm-project/pull/98125 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits