[BOLT] Fix merge-fdata handling of BAT profiles

When a profile is collected in a BOLTed binary, the generated
profile is tagged with a header string "boltedcollection" in the first
line of the fdata file. Fix merge-fdata to recognize this header
string and preserve it into the output.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D125591
This commit is contained in:
Rafael Auler 2022-05-13 15:51:36 -07:00
parent 1f7f11b951
commit 2fdc5d336e
4 changed files with 55 additions and 2 deletions

View File

@ -0,0 +1,20 @@
boltedcollection
1 main 451 1 SolveCubic 0 0 151
1 main 489 1 main 46a 0 27
1 main 4ad 1 main 428 0 135
1 main 4cb 1 main 410 2 19
1 main 4e9 1 main 3fa 0 1
1 main 521 1 usqrt 0 0 168
1 main 543 1 main 519 0 179
1 main 55c 1 usqrt 0 0 31
1 main 57f 1 main 554 0 34
1 main 5d6 1 main 58f 0 1001
1 main 62d 1 main 5e6 0 22
1 SolveCubic 82 1 SolveCubic 130 2 4
1 SolveCubic 107 1 SolveCubic 111 0 89
1 SolveCubic 12c 1 main 456 0 87
1 SolveCubic 2a6 1 main 456 0 5
1 usqrt 30 1 usqrt 39 171 2886
1 usqrt 3d 1 usqrt 10 33 4711
1 usqrt 42 1 main 526 0 73
1 usqrt 42 1 main 561 0 19

View File

@ -0,0 +1,20 @@
boltedcollection
1 main 451 1 SolveCubic 0 0 151
1 main 489 1 main 46a 0 27
1 main 4ad 1 main 428 0 135
1 main 4cb 1 main 410 2 19
1 main 4e9 1 main 3fa 0 1
1 main 521 1 usqrt 0 0 168
1 main 543 1 main 519 0 179
1 main 55c 1 usqrt 0 0 31
1 main 57f 1 main 554 0 34
1 main 5d6 1 main 58f 0 1001
1 main 62d 1 main 5e6 0 22
1 SolveCubic 82 1 SolveCubic 130 2 4
1 SolveCubic 107 1 SolveCubic 111 0 89
1 SolveCubic 12c 1 main 456 0 87
1 SolveCubic 2a6 1 main 456 0 5
1 usqrt 30 1 usqrt 39 171 2886
1 usqrt 3d 1 usqrt 10 33 4711
1 usqrt 42 1 main 526 0 73
1 usqrt 42 1 main 561 0 19

View File

@ -0,0 +1,12 @@
# Check merge-fdata tool correctly processes fdata files with header strings
# such as the ones produced by BAT mode (boltedcollection)
RUN: merge-fdata %S/Inputs/bat_profile_1.fdata \
RUN: %S/Inputs/bat_profile_2.fdata 2> %t.error \
RUN: | FileCheck %s --check-prefix=CHECK-FDATA
RUN: cat %t.error |& FileCheck %s --check-prefix=CHECK-ERROR
CHECK-ERROR-NOT: Malformed
CHECK-FDATA: 1 main 451 1 SolveCubic 0 0 302

View File

@ -257,8 +257,7 @@ void mergeLegacyProfiles(const cl::list<std::string> &Filenames) {
Filename,
"cannot mix profile collected in BOLT and non-BOLT deployments");
BoltedCollection = true;
if (!First)
Buf = Buf.drop_front(17);
Buf = Buf.drop_front(17);
} else {
if (BoltedCollection)
report_error(
@ -282,6 +281,8 @@ void mergeLegacyProfiles(const cl::list<std::string> &Filenames) {
First = false;
}
if (BoltedCollection)
outs() << "boltedcollection\n";
for (const auto &Entry : Entries)
outs() << Entry.getKey() << " " << Entry.getValue() << "\n";