aboutsummaryrefslogtreecommitdiff
path: root/bolt
diff options
context:
space:
mode:
authorAmir Ayupov <aaupov@fb.com>2024-01-18 19:44:16 -0800
committerGitHub <noreply@github.com>2024-01-18 19:44:16 -0800
commit82bc33ea3f1a539be50ed46919dc53fc6b685da9 (patch)
tree9094046be79d462bc56700661b38444a5a10ccec /bolt
parente81c981fe35483a4b7474e110ff1b5d02bc2cb00 (diff)
downloadllvm-82bc33ea3f1a539be50ed46919dc53fc6b685da9.zip
llvm-82bc33ea3f1a539be50ed46919dc53fc6b685da9.tar.gz
llvm-82bc33ea3f1a539be50ed46919dc53fc6b685da9.tar.bz2
[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.
Diffstat (limited to 'bolt')
-rw-r--r--bolt/lib/Core/BinaryEmitter.cpp1
-rw-r--r--bolt/test/X86/merge-fdata-bat-mode.test3
-rw-r--r--bolt/test/X86/merge-fdata-nobat-mode.test6
-rw-r--r--bolt/tools/merge-fdata/merge-fdata.cpp2
4 files changed, 9 insertions, 3 deletions
diff --git a/bolt/lib/Core/BinaryEmitter.cpp b/bolt/lib/Core/BinaryEmitter.cpp
index 3bff312..190c700 100644
--- a/bolt/lib/Core/BinaryEmitter.cpp
+++ b/bolt/lib/Core/BinaryEmitter.cpp
@@ -485,6 +485,7 @@ void BinaryEmitter::emitFunctionBody(BinaryFunction &BF, FunctionFragment &FF,
// This assumes the second instruction in the macro-op pair will get
// assigned to its own MCRelaxableFragment. Since all JCC instructions
// are relaxable, we should be safe.
+ Streamer.emitNeverAlignCodeAtEnd(/*Alignment to avoid=*/64, *BC.STI);
}
if (!EmitCodeOnly) {
diff --git a/bolt/test/X86/merge-fdata-bat-mode.test b/bolt/test/X86/merge-fdata-bat-mode.test
index ea3e4c3..41738e1 100644
--- a/bolt/test/X86/merge-fdata-bat-mode.test
+++ b/bolt/test/X86/merge-fdata-bat-mode.test
@@ -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
-
-
diff --git a/bolt/test/X86/merge-fdata-nobat-mode.test b/bolt/test/X86/merge-fdata-nobat-mode.test
new file mode 100644
index 0000000..870d9f8
--- /dev/null
+++ b/bolt/test/X86/merge-fdata-nobat-mode.test
@@ -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
diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp
index e21aeba..104991d 100644
--- a/bolt/tools/merge-fdata/merge-fdata.cpp
+++ b/bolt/tools/merge-fdata/merge-fdata.cpp
@@ -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";