Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorRafael Auler <rafaelauler@fb.com>2022-05-14 01:51:36 +0300
committerRafael Auler <rafaelauler@fb.com>2022-05-14 05:41:55 +0300
commit2fdc5d336ed1fdcde4700a4c23777e0959d5c8d7 (patch)
tree35531c2b030999a9a45045e3017e39fb49a01d5d /bolt
parent1f7f11b95104832a3ba046300c22e57051fa8d4e (diff)
[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
Diffstat (limited to 'bolt')
-rw-r--r--bolt/test/X86/Inputs/bat_profile_1.fdata20
-rw-r--r--bolt/test/X86/Inputs/bat_profile_2.fdata20
-rw-r--r--bolt/test/X86/merge-fdata-bat-mode.test12
-rw-r--r--bolt/tools/merge-fdata/merge-fdata.cpp5
4 files changed, 55 insertions, 2 deletions
diff --git a/bolt/test/X86/Inputs/bat_profile_1.fdata b/bolt/test/X86/Inputs/bat_profile_1.fdata
new file mode 100644
index 000000000000..68bf5afc5cb0
--- /dev/null
+++ b/bolt/test/X86/Inputs/bat_profile_1.fdata
@@ -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
diff --git a/bolt/test/X86/Inputs/bat_profile_2.fdata b/bolt/test/X86/Inputs/bat_profile_2.fdata
new file mode 100644
index 000000000000..68bf5afc5cb0
--- /dev/null
+++ b/bolt/test/X86/Inputs/bat_profile_2.fdata
@@ -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
diff --git a/bolt/test/X86/merge-fdata-bat-mode.test b/bolt/test/X86/merge-fdata-bat-mode.test
new file mode 100644
index 000000000000..911fe8f4d57a
--- /dev/null
+++ b/bolt/test/X86/merge-fdata-bat-mode.test
@@ -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
+
+
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp
index 5738219247ba..d0764646b0ae 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -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";