[llvm-branch-commits] [BOLT] Hash-based function matching (PR #95821)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jun 17 11:11:51 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: shaw young (shawbyoung)
<details>
<summary>Changes</summary>
Using the hashes of binary and profiled functions
to recover functions with changed names.
Test Plan: tbd
---
Full diff: https://github.com/llvm/llvm-project/pull/95821.diff
1 Files Affected:
- (modified) bolt/lib/Profile/YAMLProfileReader.cpp (+17)
``````````diff
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index f25f59201f1cd..f0fcb1c130002 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -415,6 +415,23 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
if (!YamlBF.Used && BF && !ProfiledFunctions.count(BF))
matchProfileToFunction(YamlBF, *BF);
+ // 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()) {
+ StrictBinaryFunctionHashes[BF.getHash()] = &BF;
+ }
+
+ for (auto YamlBF : YamlBP.Functions) {
+ auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash);
+ if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) {
+ auto *BF = It->second;
+ matchProfileToFunction(YamlBF, *BF);
+ }
+ }
+
for (yaml::bolt::BinaryFunctionProfile &YamlBF : YamlBP.Functions)
if (!YamlBF.Used && opts::Verbosity >= 1)
errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name
``````````
</details>
https://github.com/llvm/llvm-project/pull/95821
More information about the llvm-branch-commits
mailing list