[llvm] [BOLT] Hash-based function matching (PR #96572)

Maksim Panchenko via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 27 12:44:58 PDT 2024


================
@@ -374,15 +388,34 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
     // the profile.
     Function.setExecutionCount(BinaryFunction::COUNT_NO_PROFILE);
 
-    // Recompute hash once per function.
-    if (!opts::IgnoreHash)
-      Function.computeHash(YamlBP.Header.IsDFSOrder,
-                           YamlBP.Header.HashFunction);
-
-    if (profileMatches(YamlBF, Function))
+    if (profileMatches(YamlBF, Function)) {
       matchProfileToFunction(YamlBF, Function);
+      ++MatchedWithExactName;
+    }
   }
 
+  // Uses the strict hash of profiled and binary functions to match functions
+  // that are not matched by name or common name.
+  if (opts::MatchProfileWithFunctionHash) {
+    std::unordered_map<size_t, BinaryFunction *> StrictHashToBF;
----------------
maksfb wrote:

Use `DenseMap` (https://llvm.org/docs/ProgrammersManual.html#llvm-adt-densemap-h).

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


More information about the llvm-commits mailing list