llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

<details>
<summary>Changes</summary>

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


---
Full diff: https://github.com/llvm/llvm-project/pull/93760.diff


2 Files Affected:

- (modified) bolt/lib/Profile/BoltAddressTranslation.cpp (+2) 
- (modified) bolt/test/X86/register-fragments-bolt-symbols.s (+4) 


``````````diff
diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp 
b/bolt/lib/Profile/BoltAddressTranslation.cpp
index cdfca2b9871ac..7740862c33f04 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -129,6 +129,8 @@ void BoltAddressTranslation::write(const BinaryContext &BC, 
raw_ostream &OS) {
     LLVM_DEBUG(dbgs() << " Cold part\n");
     for (const FunctionFragment &FF :
          Function.getLayout().getSplitFragments()) {
+      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 d4f39b7acf134..ebcf3f31f3766 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

``````````

</details>


https://github.com/llvm/llvm-project/pull/93760
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to