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

shaw young via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 28 12:07:49 PDT 2024


================
@@ -374,15 +394,35 @@ 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. Collisions are possible in the
+  // unlikely case where multiple functions share the same exact hash.
----------------
shawbyoung wrote:

Oh I see - I thought function hashes would be quite distinct and didn't know that was the purpose of ICF - thank you!

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


More information about the llvm-commits mailing list