diff --git a/bolt/include/bolt/Core/BinaryBasicBlock.h b/bolt/include/bolt/Core/BinaryBasicBlock.h --- a/bolt/include/bolt/Core/BinaryBasicBlock.h +++ b/bolt/include/bolt/Core/BinaryBasicBlock.h @@ -427,10 +427,6 @@ /// Return branch info corresponding to an edge going to \p Succ basic block. const BinaryBranchInfo &getBranchInfo(const BinaryBasicBlock &Succ) const; - /// Return branch info corresponding to an edge going to a basic block with - /// label \p Label. - BinaryBranchInfo &getBranchInfo(const MCSymbol *Label); - /// Set branch information for the outgoing edge to block \p Succ. void setSuccessorBranchInfo(const BinaryBasicBlock &Succ, uint64_t Count, uint64_t MispredictedCount) { diff --git a/bolt/lib/Core/BinaryBasicBlock.cpp b/bolt/lib/Core/BinaryBasicBlock.cpp --- a/bolt/lib/Core/BinaryBasicBlock.cpp +++ b/bolt/lib/Core/BinaryBasicBlock.cpp @@ -593,19 +593,6 @@ return std::get<1>(*Result); } -BinaryBasicBlock::BinaryBranchInfo & -BinaryBasicBlock::getBranchInfo(const MCSymbol *Label) { - auto BI = branch_info_begin(); - for (BinaryBasicBlock *BB : successors()) { - if (BB->getLabel() == Label) - return *BI; - ++BI; - } - - llvm_unreachable("Invalid successor"); - return *BI; -} - BinaryBasicBlock *BinaryBasicBlock::splitAt(iterator II) { assert(II != end() && "expected iterator pointing to instruction"); diff --git a/bolt/lib/Passes/IndirectCallPromotion.cpp b/bolt/lib/Passes/IndirectCallPromotion.cpp --- a/bolt/lib/Passes/IndirectCallPromotion.cpp +++ b/bolt/lib/Passes/IndirectCallPromotion.cpp @@ -257,14 +257,14 @@ JT->EntrySize == BC.AsmInfo->getCodePointerSize()); for (size_t I = Range.first; I < Range.second; ++I, JI += JIAdj) { MCSymbol *Entry = JT->Entries[I]; - assert(BF.getBasicBlockForLabel(Entry) || - Entry == BF.getFunctionEndLabel() || + const BinaryBasicBlock *ToBB = BF.getBasicBlockForLabel(Entry); + assert(ToBB || Entry == BF.getFunctionEndLabel() || Entry == BF.getFunctionEndLabel(FragmentNum::cold())); if (Entry == BF.getFunctionEndLabel() || Entry == BF.getFunctionEndLabel(FragmentNum::cold())) continue; const Location To(Entry); - const BinaryBasicBlock::BinaryBranchInfo &BI = BB.getBranchInfo(Entry); + const BinaryBasicBlock::BinaryBranchInfo &BI = BB.getBranchInfo(*ToBB); Targets.emplace_back(From, To, BI.MispredictedCount, BI.Count, I - Range.first); }