[BOLT] Fix unconditional output of boltedcollection in merge-fdata (#78653)

Fix the bug where merge-fdata unconditionally outputs boltedcollection
line, regardless of whether input files have it set.

Test Plan:
Added bolt/test/X86/merge-fdata-nobat-mode.test which fails without this
fix.
This commit is contained in:
Amir Ayupov 2024-01-18 16:22:55 -08:00
parent 9fec33aadc
commit 6735ce9d25
3 changed files with 8 additions and 3 deletions

View File

@ -4,6 +4,5 @@ RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
RUN: %S/Inputs/bat_profile_2.fdata \
RUN: | FileCheck %s --check-prefix=CHECK-FDATA
CHECK-FDATA: boltedcollection
CHECK-FDATA: 1 main 451 1 SolveCubic 0 0 302

View File

@ -0,0 +1,6 @@
# Check that merge-fdata tool doesn't spuriously print boltedcollection
RUN: merge-fdata %S/Inputs/blarge.fdata %S/Inputs/blarge.fdata \
RUN: | FileCheck %s --check-prefix=CHECK-FDATA
CHECK-FDATA-NOT: boltedcollection

View File

@ -329,7 +329,7 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) {
MergedProfile.insert_or_assign(Key, Count);
}
if (BoltedCollection)
if (BoltedCollection.value_or(false))
output() << "boltedcollection\n";
for (const auto &[Key, Value] : MergedProfile)
output() << Key << " " << Value << "\n";