[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
shaw young via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Jun 17 16:00:37 PDT 2024
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821
>From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001
From: shawbyoung <shawbyoung at gmail.com>
Date: Mon, 17 Jun 2024 15:39:02 -0700
Subject: [PATCH 1/5] spr amend
Created using spr 1.3.4
---
bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index f0fcb1c130002..2bca83c9d11ec 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -421,6 +421,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size());
for (auto& [_, BF] : BC.getBinaryFunctions()) {
+ if (!ProfiledFunctions.count(&BF))
+ continue;
StrictBinaryFunctionHashes[BF.getHash()] = &BF;
}
>From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001
From: shawbyoung <shawbyoung at gmail.com>
Date: Mon, 17 Jun 2024 15:39:39 -0700
Subject: [PATCH 2/5] spr amend
Created using spr 1.3.4
---
bolt/lib/Profile/YAMLProfileReader.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index 2bca83c9d11ec..56474a67307ed 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -417,10 +417,10 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
// 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;
+ std::unordered_map<size_t, BinaryFunction *> StrictBinaryFunctionHashes;
StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size());
- for (auto& [_, BF] : BC.getBinaryFunctions()) {
+ for (auto &[_, BF] : BC.getBinaryFunctions()) {
if (!ProfiledFunctions.count(&BF))
continue;
StrictBinaryFunctionHashes[BF.getHash()] = &BF;
@@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
for (auto YamlBF : YamlBP.Functions) {
auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash);
- if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) {
+ if (It != StrictBinaryFunctionHashes.end() &&
+ !ProfiledFunctions.count(It->second)) {
auto *BF = It->second;
matchProfileToFunction(YamlBF, *BF);
}
>From 8e7b2229a69c3795e723404c56e0d4298eef412a Mon Sep 17 00:00:00 2001
From: shawbyoung <shawbyoung at gmail.com>
Date: Mon, 17 Jun 2024 15:55:58 -0700
Subject: [PATCH 3/5] spr amend
Created using spr 1.3.4
---
bolt/lib/Profile/YAMLProfileReader.cpp | 2 +-
bolt/test/X86/profile-passthrough-block.test | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index 56474a67307ed..779d60bce3b66 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -421,7 +421,7 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size());
for (auto &[_, BF] : BC.getBinaryFunctions()) {
- if (!ProfiledFunctions.count(&BF))
+ if (ProfiledFunctions.count(&BF))
continue;
StrictBinaryFunctionHashes[BF.getHash()] = &BF;
}
diff --git a/bolt/test/X86/profile-passthrough-block.test b/bolt/test/X86/profile-passthrough-block.test
index 1b875885260dc..ed2a8117ddfc4 100644
--- a/bolt/test/X86/profile-passthrough-block.test
+++ b/bolt/test/X86/profile-passthrough-block.test
@@ -57,7 +57,7 @@ header:
functions:
- name: main
fid: 0
- hash: 0x0000000000000000
+ hash: 0x0000000000000001
exec: 1
nblocks: 6
blocks:
>From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001
From: shawbyoung <shawbyoung at gmail.com>
Date: Mon, 17 Jun 2024 15:58:22 -0700
Subject: [PATCH 4/5] spr amend
Created using spr 1.3.4
---
bolt/lib/Profile/YAMLProfileReader.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index 779d60bce3b66..e3d30bfdb74e4 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -427,6 +427,8 @@ Error YAMLProfileReader::readProfile(BinaryContext &BC) {
}
for (auto YamlBF : YamlBP.Functions) {
+ if (YamlBF.Used)
+ continue;
auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash);
if (It != StrictBinaryFunctionHashes.end() &&
!ProfiledFunctions.count(It->second)) {
>From 41ce2897a445e47dfe685da66b4af080824e78ed Mon Sep 17 00:00:00 2001
From: shawbyoung <shawbyoung at gmail.com>
Date: Mon, 17 Jun 2024 16:00:27 -0700
Subject: [PATCH 5/5] spr amend
Created using spr 1.3.4
---
bolt/test/X86/profile-passthrough-block.test | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bolt/test/X86/profile-passthrough-block.test b/bolt/test/X86/profile-passthrough-block.test
index ed2a8117ddfc4..1b875885260dc 100644
--- a/bolt/test/X86/profile-passthrough-block.test
+++ b/bolt/test/X86/profile-passthrough-block.test
@@ -57,7 +57,7 @@ header:
functions:
- name: main
fid: 0
- hash: 0x0000000000000001
+ hash: 0x0000000000000000
exec: 1
nblocks: 6
blocks:
More information about the llvm-branch-commits
mailing list