[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Jun 18 20:47:21 PDT 2024


================
@@ -383,6 +381,30 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
       matchProfileToFunction(YamlBF, Function);
   }
 
+  // Uses the strict hash of profiled and binary functions to match functions
+  // that are not matched by name or common name.
+  std::unordered_map<size_t, BinaryFunction *> StrictBinaryFunctionHashes;
+  StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size());
+
+  for (auto &[_, BF] : BC.getBinaryFunctions()) {
+    if (ProfiledFunctions.count(&BF))
+      continue;
+    BF.computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction);
----------------
aaupov wrote:

Looks like we'd need to compute hashes for all functions (unless IgnoreHash is used). Let's compute them in a single place, instead of two (here and line 377).

We'd also need a sense of the runtime overhead for that – can you please run BOLT on a large binary with `-time-rewrite` and include profile reader wall time before and after into the summary?

https://github.com/llvm/llvm-project/pull/95821


More information about the llvm-branch-commits mailing list