diff options
author | Amir Ayupov <aaupov@fb.com> | 2024-07-05 15:18:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-05 15:18:49 -0700 |
commit | dc1da93958be0311b79dce39d71bd954c478cf19 (patch) | |
tree | 911d63346dd9563eb0b19c55900e8b045442f8ff | |
parent | 045e68f97b0e3d3df7be1d45e9ea3e105fff7b2a (diff) | |
download | llvm-dc1da93958be0311b79dce39d71bd954c478cf19.zip llvm-dc1da93958be0311b79dce39d71bd954c478cf19.tar.gz llvm-dc1da93958be0311b79dce39d71bd954c478cf19.tar.bz2 |
[BOLT][BAT] Add support for three-way split functions (#93760)
In three-way split functions, if only .warm fragment is present, BAT
incorrectly overwrites the map for .warm fragment by empty .cold
fragment.
Test Plan: updated register-fragments-bolt-symbols.s
-rw-r--r-- | bolt/lib/Profile/BoltAddressTranslation.cpp | 3 | ||||
-rw-r--r-- | bolt/test/X86/register-fragments-bolt-symbols.s | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp index 519f282..ec7e303 100644 --- a/bolt/lib/Profile/BoltAddressTranslation.cpp +++ b/bolt/lib/Profile/BoltAddressTranslation.cpp @@ -129,6 +129,9 @@ void BoltAddressTranslation::write(const BinaryContext &BC, raw_ostream &OS) { LLVM_DEBUG(dbgs() << " Cold part\n"); for (const FunctionFragment &FF : Function.getLayout().getSplitFragments()) { + // Skip empty fragments to avoid adding zero-address entries to maps. + if (FF.empty()) + continue; ColdPartSource.emplace(FF.getAddress(), Function.getOutputAddress()); Map.clear(); for (const BinaryBasicBlock *const BB : FF) diff --git a/bolt/test/X86/register-fragments-bolt-symbols.s b/bolt/test/X86/register-fragments-bolt-symbols.s index 5c9fb5e..c9f1859 100644 --- a/bolt/test/X86/register-fragments-bolt-symbols.s +++ b/bolt/test/X86/register-fragments-bolt-symbols.s @@ -13,8 +13,12 @@ # PREAGGWARM: B X:0 #chain.warm# 1 0 # RUN: perf2bolt %t.warm.bolt -p %t.preagg.warm --pa -o %t.warm.fdata -w %t.warm.yaml \ # RUN: -v=1 | FileCheck %s --check-prefix=CHECK-BOLT-WARM +# RUN: FileCheck %s --input-file %t.warm.fdata --check-prefix=CHECK-FDATA-WARM +# RUN: FileCheck %s --input-file %t.warm.yaml --check-prefix=CHECK-YAML-WARM # CHECK-BOLT-WARM: marking chain.warm/1(*2) as a fragment of chain +# CHECK-FDATA-WARM: chain +# CHECK-YAML-WARM: chain # RUN: sed -i 's|chain|chain/2|g' %t.fdata # RUN: llvm-objcopy --localize-symbol=chain %t.main.o |