[llvm] [BOLT] Discard BB profiles with a hash of 0 in yaml from a Post-BAT binary (PR #169627)

Jinjie Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 26 02:11:55 PST 2025


https://github.com/Jinjie-Huang updated https://github.com/llvm/llvm-project/pull/169627

>From f9bb4b70a705ae2e1268d4eb1f9ea983a5e5bce5 Mon Sep 17 00:00:00 2001
From: huangjinjie <huangjinjie at bytedance.com>
Date: Wed, 26 Nov 2025 18:11:30 +0800
Subject: [PATCH] discard BB profiles with a hash of 0

---
 bolt/lib/Profile/DataAggregator.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp
index 6b969011df589..73baceae7af55 100644
--- a/bolt/lib/Profile/DataAggregator.cpp
+++ b/bolt/lib/Profile/DataAggregator.cpp
@@ -2417,6 +2417,8 @@ std::error_code DataAggregator::writeBATYAML(BinaryContext &BC,
       // Skip printing if there's no profile data
       llvm::erase_if(
           YamlBF.Blocks, [](const yaml::bolt::BinaryBasicBlockProfile &YamlBB) {
+            if ((size_t)YamlBB.Hash == 0)
+              return true;
             auto HasCount = [](const auto &SI) { return SI.Count; };
             bool HasAnyCount = YamlBB.ExecCount ||
                                llvm::any_of(YamlBB.Successors, HasCount) ||



More information about the llvm-commits mailing list