diff --git a/0010-AArch64-Add-hybrid-guess-approach-for-edge-weight-estimation.patch b/0010-AArch64-Add-hybrid-guess-approach-for-edge-weight-estimation.patch new file mode 100644 index 0000000000000000000000000000000000000000..206136ce1262bbcef70b6f6529b0eae7673d32e3 --- /dev/null +++ b/0010-AArch64-Add-hybrid-guess-approach-for-edge-weight-estimation.patch @@ -0,0 +1,74 @@ +From 43aa1ec5b46baf032cf2fee22d765a195d40cf59 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?=E7=89=9F=E6=96=87=E9=BE=99?= +Date: Mon, 18 Nov 2024 02:13:25 +0000 +Subject: [PATCH] [AArch64] Add hybrid guess approach for edge weight + estimation + +--- + bolt/lib/Passes/MCF.cpp | 33 +++++++++++++++++++++++++++++++-- + 1 file changed, 31 insertions(+), 2 deletions(-) + +diff --git a/bolt/lib/Passes/MCF.cpp b/bolt/lib/Passes/MCF.cpp +index c3898d2dc..a6455bbeb 100644 +--- a/bolt/lib/Passes/MCF.cpp ++++ b/bolt/lib/Passes/MCF.cpp +@@ -36,6 +36,11 @@ static cl::opt IterativeGuess( + cl::desc("in non-LBR mode, guess edge counts using iterative technique"), + cl::Hidden, cl::cat(BoltOptCategory)); + ++static cl::opt HybridGuess( ++ "hybrid-guess", ++ cl::desc("in non-LBR mode, guess edge counts using hybird estimation technique"), ++ cl::Hidden, cl::cat(BoltOptCategory)); ++ + static cl::opt UseRArcs( + "mcf-use-rarcs", + cl::desc("in MCF, consider the possibility of cancelling flow to balance " +@@ -350,6 +355,27 @@ void guessEdgeByIterativeApproach(BinaryFunction &BF) { + } + } + ++void guessEdgeByHybridApproach(BinaryFunction &BF, ++ EdgeWeightMap &PredEdgeWeights, ++ EdgeWeightMap &SuccEdgeWeights) { ++ for (BinaryBasicBlock &BB : BF) { ++ for (BinaryBasicBlock *Pred : BB.predecessors()) { ++ double RelativeExecSucc = SuccEdgeWeights[std::make_pair(Pred, &BB)]; ++ double RelativeExec = PredEdgeWeights[std::make_pair(Pred, &BB)]; ++ RelativeExec *= BB.getExecutionCount(); ++ RelativeExecSucc *= Pred->getExecutionCount(); ++ BinaryBasicBlock::BinaryBranchInfo &BI = Pred->getBranchInfo(BB); ++ if ((static_cast(RelativeExec) != 0) && (static_cast(RelativeExecSucc) != 0)) { ++ BI.Count = (static_cast(RelativeExec) + RelativeExecSucc) / 2; ++ } else if (static_cast(RelativeExec) != 0) { ++ BI.Count = static_cast(RelativeExec); ++ } else if (static_cast(RelativeExecSucc) != 0) { ++ BI.Count = static_cast(RelativeExecSucc); ++ } ++ } ++ } ++} ++ + /// Associate each basic block with the BinaryLoop object corresponding to the + /// innermost loop containing this block. + DenseMap +@@ -454,11 +480,14 @@ void estimateEdgeCounts(BinaryFunction &BF) { + equalizeBBCounts(Info, BF); + LLVM_DEBUG(BF.print(dbgs(), "after equalize BB counts")); + } +- if (opts::IterativeGuess) ++ if (opts::IterativeGuess) { + guessEdgeByIterativeApproach(BF); +- else ++ } else if (opts::HybridGuess) { ++ guessEdgeByHybridApproach(BF, PredEdgeWeights, SuccEdgeWeights); ++ } else { + guessEdgeByRelHotness(BF, /*UseSuccs=*/false, PredEdgeWeights, + SuccEdgeWeights); ++ } + recalculateBBCounts(BF, /*AllEdges=*/false); + } + +-- +2.25.1 + diff --git a/llvm-bolt.spec b/llvm-bolt.spec index 5154975000eacbc864dc1339a3cb244f65010003..f917b04df22059f8029d9897642faeff4b9a44d7 100644 --- a/llvm-bolt.spec +++ b/llvm-bolt.spec @@ -22,7 +22,7 @@ Name: %{pkg_name} Version: %{bolt_version} -Release: 10 +Release: 11 Summary: BOLT is a post-link optimizer developed to speed up large applications License: Apache 2.0 URL: https://github.com/llvm/llvm-project/tree/main/bolt @@ -39,6 +39,7 @@ Patch6: 0006-AArch64-Add-CFG-block-count-correction-optimization.patch Patch7: 0007-BOLT-Skip-PLT-search-for-zero-value-weak-reference-symbols.patch Patch8: 0008-merge-fdata-Support-process-no_lbr-profile-file.patch Patch9: 0009-support-aarch64-instrumentation.patch +Patch10: 0010-AArch64-Add-hybrid-guess-approach-for-edge-weight-estimation.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -154,6 +155,12 @@ rm -f %{buildroot}/%{_builddir}/%{bolt_srcdir}/%{_vpath_builddir}/%{_lib}/lib*.a %doc %{install_docdir} %changelog +* Mon Nov 18 2024 mwl2000 17.0.6-11 +- Type:Feature +- ID:NA +- SUG:NA +- DESC: Add hybrid guess approach for edge weight estimation. + * Thu Oct 31 2024 rfwang07 17.0.6-10 - Type:Backport - ID:NA