[Bugfix] Enable merge-fdata support processing no-lbr profile

This commit is contained in:
liyancheng 2024-09-10 15:18:23 +08:00
parent 986833672d
commit 6d11fb7d60
2 changed files with 66 additions and 1 deletions

View File

@ -0,0 +1,58 @@
From 583d41ce046670eae7a59fb678a9e959cf0af061 Mon Sep 17 00:00:00 2001
From: liyancheng <412998149@qq.com>
Date: Tue, 10 Sep 2024 15:09:51 +0800
Subject: [PATCH] [merge-fdata] Support processing no_lbr profile file
---
bolt/tools/merge-fdata/merge-fdata.cpp | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp
index 757f05366..147e18639 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -261,6 +261,7 @@ bool isYAML(const StringRef Filename) {
void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
errs() << "Using legacy profile format.\n";
std::optional<bool> BoltedCollection;
+ std::optional<bool> NoLBRMode;
std::mutex BoltedCollectionMutex;
typedef StringMap<uint64_t> ProfileTy;
@@ -294,6 +295,22 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
BoltedCollection = false;
}
+ // Check if the string "no_lbr" is in the first line
+ if (Buf.startswith("no_lbr")) {
+ if (!NoLBRMode.value_or(true))
+ report_error(
+ Filename,
+ "cannot mix profile collected with lbr and non-lbr info");
+ NoLBRMode = true;
+ Buf = Buf.drop_front(Buf.find_first_of("\n"));
+ } else {
+ if (NoLBRMode.value_or(false))
+ report_error(
+ Filename,
+ "cannot mix profile collected with lbr and non-lbr info");
+ NoLBRMode = false;
+ }
+
Profile = &Profiles[tid];
}
@@ -329,7 +346,9 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
MergedProfile.insert_or_assign(Key, Count);
}
- if (BoltedCollection)
+ if (NoLBRMode)
+ output() << "no_lbr cycles:u:\n";
+ else if (BoltedCollection)
output() << "boltedcollection\n";
for (const auto &[Key, Value] : MergedProfile)
output() << Key << " " << Value << "\n";
--
2.33.0

View File

@ -22,7 +22,7 @@
Name: %{pkg_name}
Version: %{bolt_version}
Release: 8
Release: 9
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
@ -37,6 +37,7 @@ Patch4: 0004-Bolt-Solving-pie-support-issue.patch
Patch5: 0005-BOLT-AArch64-Don-t-change-layout-in-PatchEntries.patch
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
BuildRequires: gcc
BuildRequires: gcc-c++
@ -148,6 +149,12 @@ rm -f %{buildroot}/%{_builddir}/%{bolt_srcdir}/%{_vpath_builddir}/%{_lib}/lib*.a
%doc %{install_docdir}
%changelog
* Tue Sep 10 2024 liyancheng <412998149@qq.com> 17.0.6-9
- Type:Bugfix
- ID:NA
- SUG:NA
- DESC: Enable merge-fdata support processing no-lbr profile.
* Wed Sep 04 2024 rfwang07 <wangrufeng5@huawei.com> 17.0.6-8
- Type:Backport
- ID:NA