diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -902,10 +902,6 @@ return false; } - // Record fall-through jumps - BinaryBasicBlock::BinaryBranchInfo &BI = BB->getBranchInfo(*NextBB); - BI.Count += Count; - if (Branches) { const MCInst *Instr = BB->getLastNonPseudoInstr(); uint64_t Offset = 0; @@ -920,6 +916,15 @@ BB = NextBB; } + // Record fall-through jumps + for (const auto &[FromOffset, ToOffset] : *Branches) { + BinaryBasicBlock *FromBB = BF.getBasicBlockContainingOffset(FromOffset); + BinaryBasicBlock *ToBB = BF.getBasicBlockAtOffset(ToOffset); + assert(FromBB && ToBB); + BinaryBasicBlock::BinaryBranchInfo &BI = FromBB->getBranchInfo(*ToBB); + BI.Count += Count; + } + return true; }