llvm-bolt/0008-merge-fdata-Support-process-no_lbr-profile-file.patch
rfwang07 e94a123c64 Sync patch from 2203sp4
(cherry picked from commit 814120db4bcb4fae1fe36b043cdeee2ee0d0a47e)
2024-11-22 10:45:19 +08:00

59 lines
2.0 KiB
Diff

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