[llvm-branch-commits] [llvm] [BOLT] Add secondary entry points to BAT (PR #86218)

Amir Ayupov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 25 13:07:54 PDT 2024


https://github.com/aaupov updated https://github.com/llvm/llvm-project/pull/86218

>From 6bc606b39044876a883aebc68fc5bbc8699094c5 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Sat, 23 Mar 2024 16:36:36 -0700
Subject: [PATCH 1/2] Fix test

Created using spr 1.3.4
---
 bolt/test/X86/bolt-address-translation-yaml.test | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/test/X86/bolt-address-translation-yaml.test b/bolt/test/X86/bolt-address-translation-yaml.test
index be3bcb2a0c6dd1..306050a1c97e2b 100644
--- a/bolt/test/X86/bolt-address-translation-yaml.test
+++ b/bolt/test/X86/bolt-address-translation-yaml.test
@@ -18,7 +18,7 @@ RUN:   | FileCheck --check-prefix CHECK-BOLT-YAML %s
 
 WRITE-BAT-CHECK: BOLT-INFO: Wrote 5 BAT maps
 WRITE-BAT-CHECK: BOLT-INFO: Wrote 4 function and 22 basic block hashes
-WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 380
+WRITE-BAT-CHECK: BOLT-INFO: BAT section size (bytes): 384
 
 READ-BAT-CHECK-NOT: BOLT-ERROR: unable to save profile in YAML format for input file processed by BOLT
 READ-BAT-CHECK: BOLT-INFO: Parsed 5 BAT entries

>From cdf326b7bc0f1a91cc7556d4ffa105d9072c6e89 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Mon, 25 Mar 2024 13:07:43 -0700
Subject: [PATCH 2/2] Address comments, add openssl test

Created using spr 1.3.4
---
 bolt/lib/Profile/BoltAddressTranslation.cpp | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/bolt/lib/Profile/BoltAddressTranslation.cpp b/bolt/lib/Profile/BoltAddressTranslation.cpp
index 9d4ad3bcf9b429..aa4cde27e75cdb 100644
--- a/bolt/lib/Profile/BoltAddressTranslation.cpp
+++ b/bolt/lib/Profile/BoltAddressTranslation.cpp
@@ -194,7 +194,7 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
     PrevAddress = Address;
     const uint32_t NumSecondaryEntryPoints =
         SecondaryEntryPointsMap.count(Address)
-            ? SecondaryEntryPointsMap.at(Address).size()
+            ? SecondaryEntryPointsMap[Address].size()
             : 0;
     if (Cold) {
       size_t HotIndex =
@@ -263,7 +263,7 @@ void BoltAddressTranslation::writeMaps(std::map<uint64_t, MapTy> &Maps,
     if (!Cold && NumSecondaryEntryPoints) {
       LLVM_DEBUG(dbgs() << "Secondary entry points: ");
       // Secondary entry point offsets, delta-encoded
-      for (uint32_t Offset : SecondaryEntryPointsMap.at(Address)) {
+      for (uint32_t Offset : SecondaryEntryPointsMap[Address]) {
         encodeULEB128(Offset - PrevOffset, OS);
         LLVM_DEBUG(dbgs() << formatv("{0:x} ", Offset));
         PrevOffset = Offset;
@@ -443,6 +443,13 @@ void BoltAddressTranslation::dump(raw_ostream &OS) {
         OS << formatv(" hash: {0:x}", BBHashMap.getBBHash(Val));
       OS << "\n";
     }
+    if (SecondaryEntryPointsMap.count(Address)) {
+      const std::vector<uint32_t> &SecondaryEntryPoints =
+          SecondaryEntryPointsMap[Address];
+      OS << SecondaryEntryPoints.size() << " secondary entry points:\n";
+      for (uint32_t EntryPointOffset : SecondaryEntryPoints)
+        OS << formatv("{0:x}\n", EntryPointOffset);
+    }
     OS << "\n";
   }
   const size_t NumColdParts = ColdPartSource.size();



More information about the llvm-branch-commits mailing list