[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/20] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/20] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/20] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/20] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/20] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/20] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/20] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/20] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/20] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/20] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/20] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/20] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/20] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/20] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/20] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/19] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/19] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/19] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/19] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/19] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +386,34 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { // 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. + if (opts::MatchProfileWithFunctionHash) { +std::unordered_map StrictHashToBF; +StrictHashToBF.reserve(BC.getBinaryFunctions().size()); + +for (auto &[_, BF] : BC.getBinaryFunctions()) + StrictHashToBF[BF.getHash()] = + +for (yaml::bolt::BinaryFunctionProfile : YamlBP.Functions) { + if (YamlBF.Used) +continue; + auto It = StrictHashToBF.find(YamlBF.Hash); + if (It != StrictHashToBF.end() && !ProfiledFunctions.count(It->second)) { +auto *BF = It->second; aaupov wrote: nit: LLVM's guideline is to use explicit type here: [LLVM Coding Standards](https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable) https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -0,0 +1,65 @@ +## Test YAMLProfileReader support for pass-through blocks in non-matching edges: +## match the profile edge A -> C to the CFG with blocks A -> B -> C. aaupov wrote: Please update the test description. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/aaupov approved this pull request. LG overall, with a couple of nits. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -439,6 +482,11 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { BC.setNumUnusedProfiledObjects(NumUnused); + if (opts::Lite) +for (BinaryFunction *BF : BC.getAllBinaryFunctions()) + if (ProfiledFunctions.find(BF) == ProfiledFunctions.end()) aaupov wrote: At this point we're supposed to have attached the profile to BF: ```suggestion if (!BF->hasProfile()) ``` https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/18] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/18] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/18] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/18] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/18] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/17] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/17] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/17] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/17] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/17] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/16] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/16] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/16] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/16] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/16] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/15] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/15] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/15] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/15] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/15] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung edited https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -1161,4 +1165,4 @@ - `--print-options` - Print non-default options after command line parsing shawbyoung wrote: Didn't touch this line - diff return nothing when applied to "added" and "deleted" line - maybe it's some git corner case? https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +393,34 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { // 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. + if (opts::MatchingFunctionsWithHash) { shawbyoung wrote: In BOLT, a strict hash captures a binary function's block order as well as each blocks' instructions & opcodes. So, the goal of this PR is to recover block-identical functions that have been simply been renamed. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +393,34 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { // 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. + if (opts::MatchingFunctionsWithHash) { WenleiHe wrote: What is captured in strict hash? For reference, function hash for compiler PGO isn't very strict, and it's not strong enough for small functions. So we use comprehensive graph matching in addition to hash matching to recover renamed function/profile pair. Change in https://github.com/llvm/llvm-project/pull/95135 cc @wlei-llvm https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -363,9 +364,27 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { return Profile.Hash == static_cast(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 = *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 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -2982,6 +2983,9 @@ void RewriteInstance::selectFunctionsToProcess() { if (mustSkip(Function)) return false; +if (opts::MatchingFunctionsWithHash) + return true; aaupov wrote: Since we're forcing the processing of all functions here to construct CFG and compute hashes, let's also mark functions without profile as ignored in Lite mode. This should happen after we assign profile, at the end of YAMLProfileReader::readProfile. Under the new option, go over all functions and check if the function has profile, if not, mark it ignored. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -128,6 +128,11 @@ cl::opt cl::desc("instrument code to generate accurate profile data"), cl::cat(BoltOptCategory)); +cl::opt +MatchingFunctionsWithHash("stale-matching-matching-functions-with-hash", + cl::desc("Matching functions using hash"), aaupov wrote: Technically it's independent of stale matching: ```suggestion MatchProfileWithFunctionHash("match-profile-with-function-hash", cl::desc("Match profile with function hash"), ``` https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -1161,4 +1165,4 @@ - `--print-options` - Print non-default options after command line parsing aaupov wrote: nit: please avoid unrelated changes https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/14] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/14] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/14] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/14] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/14] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung edited https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/13] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/13] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/13] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/13] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/13] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/12] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/12] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/12] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/12] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/12] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/11] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/11] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/11] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/11] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/11] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 01/10] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 02/10] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 03/10] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 04/10] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 05/10] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 1/9] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 2/9] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 3/9] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 4/9] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 5/9] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +377,33 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { // 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 StrictHashToBF; +StrictHashToBF.reserve(BC.getBinaryFunctions().size()); + +for (auto &[_, BF] : BC.getBinaryFunctions()) { + StrictHashToBF[BF.getHash()] = +} + +for (auto YamlBF : YamlBP.Functions) { ayermolo wrote: Specify actual type. This can also hide copy since & is not used. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -374,15 +377,33 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { // 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 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 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 1/8] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 2/8] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 3/8] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 4/8] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 5/8] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 1/7] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 2/7] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 3/7] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 4/7] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 5/7] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/aaupov commented: Looks very good, but please address some minor issues. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -383,6 +381,30 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { matchProfileToFunction(YamlBF, Function); } + // Uses the strict hash of profiled and binary functions to match functions + // that are not matched by name or common name. + std::unordered_map StrictBinaryFunctionHashes; aaupov wrote: ```suggestion std::unordered_map StrictHashToBF; ``` https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/aaupov edited https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -383,6 +381,30 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { matchProfileToFunction(YamlBF, Function); } + // Uses the strict hash of profiled and binary functions to match functions + // that are not matched by name or common name. + std::unordered_map StrictBinaryFunctionHashes; + StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); + + for (auto &[_, BF] : BC.getBinaryFunctions()) { +if (ProfiledFunctions.count()) + continue; +BF.computeHash(YamlBP.Header.IsDFSOrder, YamlBP.Header.HashFunction); aaupov wrote: Looks like we'd need to compute hashes for all functions (unless IgnoreHash is used). Let's compute them in a single place, instead of two (here and line 377). We'd also need a sense of the runtime overhead for that – can you please run BOLT on a large binary with `-time-rewrite` and include profile reader wall time before and after into the summary? https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -383,6 +381,30 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { matchProfileToFunction(YamlBF, Function); } + // Uses the strict hash of profiled and binary functions to match functions aaupov wrote: Let's put this under `if (!opts::IgnoreHash)` https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -420,6 +442,7 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { errs() << "BOLT-WARNING: profile ignored for function " << YamlBF.Name << '\n'; + aaupov wrote: nit: please drop https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
@@ -0,0 +1,67 @@ +## Test YAMLProfileReader support for pass-through blocks in non-matching edges: +## match the profile edge A -> C to the CFG with blocks A -> B -> C. + +# REQUIRES: system-linux +# RUN: split-file %s %t +# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %t/main.s -o %t.o +# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q -nostdlib +# RUN: llvm-bolt %t.exe -o %t.out --data %t/yaml -v=1 \ +# RUN: --print-cfg 2>&1 | FileCheck %s aaupov wrote: Please add verbosity=2 logging for hash-based matching and explicitly check that we matched `main` BF to `main2` profile. https://github.com/llvm/llvm-project/pull/95821 ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 1/6] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 2/6] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 3/6] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 4/6] 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 ) { } 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 Date: Mon, 17 Jun 2024 16:00:27 -0700 Subject: [PATCH 5/6] 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung 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 ) { } 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 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
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 1/4] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 2/4] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 3/4] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: >From ef5f0dac9185dbb7a62345938d4f309c3379a85d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:58:22 -0700 Subject: [PATCH 4/4] 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 ) { } for (auto YamlBF : YamlBP.Functions) { +if (YamlBF.Used) + continue; auto It = StrictBinaryFunctionHashes.find(YamlBF.Hash); if (It != StrictBinaryFunctionHashes.end() && !ProfiledFunctions.count(It->second)) { ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 1/3] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 2/3] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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 Date: Mon, 17 Jun 2024 15:55:58 -0700 Subject: [PATCH 3/3] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto &[_, BF] : BC.getBinaryFunctions()) { -if (!ProfiledFunctions.count()) +if (ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = } 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:0x +hash:0x0001 exec:1 nblocks: 6 blocks: ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH 1/2] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } >From 2497922ccc46e3189870563b1fe819b67172778d Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:39 -0700 Subject: [PATCH 2/2] 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 ) { // Uses the strict hash of profiled and binary functions to match functions // that are not matched by name or common name. - std::unordered_map StrictBinaryFunctionHashes; + std::unordered_map StrictBinaryFunctionHashes; StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); - for (auto& [_, BF] : BC.getBinaryFunctions()) { + for (auto &[_, BF] : BC.getBinaryFunctions()) { if (!ProfiledFunctions.count()) continue; StrictBinaryFunctionHashes[BF.getHash()] = @@ -428,7 +428,8 @@ Error YAMLProfileReader::readProfile(BinaryContext ) { 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); } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
[llvm-branch-commits] [llvm] [BOLT] Hash-based function matching (PR #95821)
https://github.com/shawbyoung updated https://github.com/llvm/llvm-project/pull/95821 >From 92212c96ea169d26ac10bf8d750539bc5dd72c49 Mon Sep 17 00:00:00 2001 From: shawbyoung Date: Mon, 17 Jun 2024 15:39:02 -0700 Subject: [PATCH] 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 ) { StrictBinaryFunctionHashes.reserve(BC.getBinaryFunctions().size()); for (auto& [_, BF] : BC.getBinaryFunctions()) { +if (!ProfiledFunctions.count()) + continue; StrictBinaryFunctionHashes[BF.getHash()] = } ___ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits