[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
Sun Nov 30 21:36:07 PST 2025


Jinjie-Huang wrote:

@aaupov What's confusing is that the BAT writer appears to have special logic for handling these BBs inserted by BOLT's optimizations([code](https://github.com/llvm/llvm-project/blob/llvmorg-22-init/bolt/lib/Profile/BoltAddressTranslation.cpp#L271)): It first reads the post-optimized function's BB map (generated in writeMaps()) to get the InOffset, and then checks if this offset belongs to a BB in the original binary. If it doesn't, it sets both the BBIndex and the hash to 0. This would explain why we see a zero hash for the zero-ID BB in Curl_client_write.

If we're dealing with a BAT file that might contain zero-hash BBs and is intended for iterative YAML profile generation, then it seems reasonable to drop them. This approach would preserve BOLT's ability to use infer-stale-profile on the YAML profile.

https://github.com/llvm/llvm-project/pull/169627


More information about the llvm-commits mailing list