[llvm-branch-commits] [llvm] [BOLT][NFC] Split up StaleProfileMatching::matchWeights (PR #165492)
Amir Ayupov via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Tue Oct 28 21:39:55 PDT 2025
https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/165492
>From 49643f04d7f915e3f1cd4a58f4d01fa2767221a9 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Tue, 28 Oct 2025 19:57:49 -0700
Subject: [PATCH 1/2] clang-format
Created using spr 1.3.4
---
bolt/lib/Profile/StaleProfileMatching.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/bolt/lib/Profile/StaleProfileMatching.cpp b/bolt/lib/Profile/StaleProfileMatching.cpp
index 129fc9acc84a7..af0797ef198ae 100644
--- a/bolt/lib/Profile/StaleProfileMatching.cpp
+++ b/bolt/lib/Profile/StaleProfileMatching.cpp
@@ -724,18 +724,18 @@ size_t setBlockWeights(FlowFunction &Func, ArrayRef<uint64_t> OutWeight,
/// of the basic blocks in the binary, the count is "matched" to the block.
/// Similarly, if both the source and the target of a count in the profile are
/// matched to a jump in the binary, the count is recorded in CFG.
-size_t matchWeights(BinaryContext &BC,
- const BinaryFunction::BasicBlockOrderType &BlockOrder,
- const yaml::bolt::BinaryFunctionProfile &YamlBF,
- FlowFunction &Func, HashFunction HashFunction,
- YAMLProfileReader::ProfileLookupMap &IdToYamlBF,
- const BinaryFunction &BF,
- const ArrayRef<YAMLProfileReader::ProbeMatchSpec> ProbeMatchSpecs) {
+size_t matchWeights(
+ BinaryContext &BC, const BinaryFunction::BasicBlockOrderType &BlockOrder,
+ const yaml::bolt::BinaryFunctionProfile &YamlBF, FlowFunction &Func,
+ HashFunction HashFunction, YAMLProfileReader::ProfileLookupMap &IdToYamlBF,
+ const BinaryFunction &BF,
+ const ArrayRef<YAMLProfileReader::ProbeMatchSpec> ProbeMatchSpecs) {
using namespace yaml::bolt;
assert(Func.Blocks.size() == BlockOrder.size() + 2);
- auto [Matcher, BlendedHashes] = initMatcher(BC, BlockOrder, Func, HashFunction);
+ auto [Matcher, BlendedHashes] =
+ initMatcher(BC, BlockOrder, Func, HashFunction);
// Match jumps from the profile to the jumps from CFG
std::vector<uint64_t> OutWeight(Func.Blocks.size(), 0);
>From 3ed63babd3e8503214a519728cf93e5b0772d3e8 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Tue, 28 Oct 2025 21:39:45 -0700
Subject: [PATCH 2/2] reduce changes
Created using spr 1.3.4
---
bolt/lib/Profile/StaleProfileMatching.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bolt/lib/Profile/StaleProfileMatching.cpp b/bolt/lib/Profile/StaleProfileMatching.cpp
index 2e9678bed8e36..f1cffde975520 100644
--- a/bolt/lib/Profile/StaleProfileMatching.cpp
+++ b/bolt/lib/Profile/StaleProfileMatching.cpp
@@ -684,6 +684,7 @@ matchBlocks(BinaryContext &BC, const yaml::bolt::BinaryFunctionProfile &YamlBF,
}
addMatchedBlock({MatchedBlock, Method}, YamlBF, YamlBB);
}
+
for (const auto &[YamlBBIdx, FlowBlockProfile] : MatchedBlocks) {
const auto &[MatchedBlock, YamlBB] = FlowBlockProfile;
StaleMatcher::MatchMethod Method = MatchedFlowBlocks.lookup(MatchedBlock);
@@ -735,9 +736,8 @@ void transferEdgeWeights(ProfileBlockMatchMap &MatchedBlocks,
MutableArrayRef<uint64_t> OutWeight,
MutableArrayRef<uint64_t> InWeight,
const yaml::bolt::BinaryFunctionProfile &YamlBF) {
- using namespace yaml::bolt;
- for (const BinaryBasicBlockProfile &YamlBB : YamlBF.Blocks) {
- for (const SuccessorInfo &YamlSI : YamlBB.Successors) {
+ for (const yaml::bolt::BinaryBasicBlockProfile &YamlBB : YamlBF.Blocks) {
+ for (const yaml::bolt::SuccessorInfo &YamlSI : YamlBB.Successors) {
if (YamlSI.Count == 0)
continue;
More information about the llvm-branch-commits
mailing list