[BOLT][merge-fdata] Fix basic sample profile aggregation without LBR info (#118481)
When a basic sample profile is gathered without LBR info, the generated profile contains a "no-lbr" tag in the first line of the fdata file. This PR fixes merge-fdata to recognize and save this tag to the output file.
This commit is contained in:
@@ -265,6 +265,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> NoLBRCollection;
|
||||
std::mutex BoltedCollectionMutex;
|
||||
typedef StringMap<uint64_t> ProfileTy;
|
||||
|
||||
@@ -297,7 +298,22 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
|
||||
"cannot mix profile collected in BOLT and non-BOLT deployments");
|
||||
BoltedCollection = false;
|
||||
}
|
||||
|
||||
// Check if the string "no_lbr" is in the first line
|
||||
// (or second line if BoltedCollection is true)
|
||||
size_t CheckNoLBRPos = Buf.find('\n');
|
||||
if (CheckNoLBRPos != StringRef::npos) {
|
||||
StringRef FirstLine = Buf.substr(0, CheckNoLBRPos);
|
||||
if (FirstLine.contains("no_lbr")) {
|
||||
if (!NoLBRCollection.value_or(true))
|
||||
report_error(Filename, "cannot mix 'no_lbr' and 'lbr' profiles");
|
||||
NoLBRCollection = true;
|
||||
Buf = Buf.drop_front(CheckNoLBRPos + 1);
|
||||
} else {
|
||||
if (NoLBRCollection.value_or(false))
|
||||
report_error(Filename, "cannot mix 'no_lbr' and 'lbr' profiles");
|
||||
NoLBRCollection = false;
|
||||
}
|
||||
}
|
||||
Profile = &Profiles[tid];
|
||||
}
|
||||
|
||||
@@ -336,6 +352,8 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
|
||||
|
||||
if (BoltedCollection.value_or(false))
|
||||
output() << "boltedcollection\n";
|
||||
if (NoLBRCollection.value_or(false))
|
||||
output() << "no_lbr\n";
|
||||
for (const auto &[Key, Value] : MergedProfile)
|
||||
output() << Key << " " << Value << "\n";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user