[llvm] [BOLT][NFC] Add BinaryContext::HasBATSection (PR #92650)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Sat May 18 07:30:05 PDT 2024


https://github.com/aaupov created https://github.com/llvm/llvm-project/pull/92650

Currently, the presence of a BAT section is known only at
RewriteInstance level. Add a flag at BinaryContext level.


>From 3d5ca74407e90ee1cf7ecb93823b44f5b3d72859 Mon Sep 17 00:00:00 2001
From: Amir Ayupov <aaupov at fb.com>
Date: Sat, 18 May 2024 07:27:15 -0700
Subject: [PATCH] [BOLT][NFC] Add BinaryContext::HasBATSection

Currently, the presence of a BAT section is known only at
RewriteInstance level. Add a flag at BinaryContext level.
---
 bolt/include/bolt/Core/BinaryContext.h | 3 +++
 bolt/lib/Rewrite/RewriteInstance.cpp   | 1 +
 2 files changed, 4 insertions(+)

diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h
index 75765819ac464..edd0f7d2365a4 100644
--- a/bolt/include/bolt/Core/BinaryContext.h
+++ b/bolt/include/bolt/Core/BinaryContext.h
@@ -677,6 +677,9 @@ class BinaryContext {
   /// have an origin file name available.
   bool HasSymbolsWithFileName{false};
 
+  /// Does the binary have BAT section.
+  bool HasBATSection{false};
+
   /// Sum of execution count of all functions
   uint64_t SumExecutionCount{0};
 
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 85b39176754b6..fa5167490923c 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -1988,6 +1988,7 @@ Error RewriteInstance::readSpecialSections() {
 
   if (ErrorOr<BinarySection &> BATSec =
           BC->getUniqueSectionByName(BoltAddressTranslation::SECTION_NAME)) {
+    BC->HasBATSection = true;
     // Do not read BAT when plotting a heatmap
     if (!opts::HeatmapMode) {
       if (std::error_code EC = BAT->parse(BC->outs(), BATSec->getContents())) {



More information about the llvm-commits mailing list