[llvm-branch-commits] [llvm] [BOLT] Match functions with call graph (PR #98125)
Shaw Young via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Jul 16 15:54:05 PDT 2024
================
@@ -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
----------------
shawbyoung wrote:
1. In a binary with 953488 binary functions and 13376 profiled functions, the largest bucket had 151 functions. This however was an outlier - the median & mean bucket size was 2 and ~5 respectively and more than half of buckets only had one binary function.
2. I agree - just implemented LCP name matching as opposed to block count.
https://github.com/llvm/llvm-project/pull/98125
More information about the llvm-branch-commits
mailing list