[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
Amir Ayupov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Jun 21 11:26:28 PDT 2024
================
@@ -363,9 +364,27 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
return Profile.Hash == static_cast<uint64_t>(BF.getHash());
};
- // We have to do 2 passes since LTO introduces an ambiguity in function
- // names. The first pass assigns profiles that match 100% by name and
- // by hash. The second pass allows name ambiguity for LTO private functions.
+ uint64_t MatchedWithExactName = 0;
+ uint64_t MatchedWithHash = 0;
+ uint64_t MatchedWithLTOCommonName = 0;
+
+ // Computes hash for binary functions.
+ if (opts::MatchingFunctionsWithHash) {
+ for (auto &[_, BF] : BC.getBinaryFunctions())
+ BF.computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction);
+ } else {
+ for (auto [YamlBF, BF] : llvm::zip_equal(YamlBP.Functions, ProfileBFs)) {
+ if (!BF)
+ continue;
+ BinaryFunction &Function = *BF;
+
+ if (!opts::IgnoreHash)
+ Function.computeHash(YamlBP.Header.IsDFSOrder,
+ YamlBP.Header.HashFunction);
+ }
+ }
----------------
aaupov wrote:
```suggestion
if (opts::MatchingFunctionsWithHash)
for (auto &[_, BF] : BC.getBinaryFunctions())
BF.computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction);
else if (!opts::IgnoreHash)
for (BinaryFunction *BF : ProfileBFs)
BF->computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction);
```
https://github.com/llvm/llvm-project/pull/95821
More information about the llvm-branch-commits
mailing list