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

Alexander Yermolovich via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Jun 20 10:59:24 PDT 2024


================
@@ -374,15 +377,33 @@ 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))
       matchProfileToFunction(YamlBF, Function);
   }
 
+  // Uses the strict hash of profiled and binary functions to match functions
+  // that are not matched by name or common name.
+  if (!opts::IgnoreHash) {
+    std::unordered_map<size_t, BinaryFunction *> StrictHashToBF;
+    StrictHashToBF.reserve(BC.getBinaryFunctions().size());
+
+    for (auto &[_, BF] : BC.getBinaryFunctions()) {
----------------
ayermolo wrote:

no need for {} since it's one line.

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


More information about the llvm-branch-commits mailing list