[llvm] [BOLT][ICP] Propagate parent hash to newly inserted BBs for BAT (PR #171044)

Jinjie Huang via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 10 04:51:15 PST 2025


================
@@ -440,6 +442,26 @@ void BinaryFunction::computeBlockHashes(HashFunction HashFunction) const {
     BB->setHash(BlendedHashes[I].combine());
   }
 }
+
+void BinaryFunction::updateInsertedBBHashMap(
+    const BinaryBasicBlock &OriginBB,
+    const std::vector<std::unique_ptr<BinaryBasicBlock>> &BBs) {
+  if (!opts::EnableBAT || !OriginBB.getFunction() || !OriginBB.getHash())
+    return;
+
+  auto &BBHashMap =
+      BC.getBAT()->getBBHashMap(OriginBB.getFunction()->getAddress());
+
+  for (const auto &BB : BBs) {
+    if (!BB)
+      continue;
+    // Update BB and BBHashMap using the original BB's index and hash.
+    BB->setHash(OriginBB.getHash());
----------------
Jinjie-Huang wrote:

Update inserted BBs' information as well, in case they are used as OriginBBs later.

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


More information about the llvm-commits mailing list