diff --git a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 9509e5234840f..66ea5ecbc4bfb 100644 --- a/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -1571,7 +1571,8 @@ void BlockFrequencyInfoImpl::initTransitionProbabilities( SmallPtrSet UniqueSuccs; for (const auto SI : children(BB)) { // Ignore cold blocks - if (!BlockIndex.contains(SI)) + auto BlockIndexIt = BlockIndex.find(SI); + if (BlockIndexIt == BlockIndex.end()) continue; // Ignore parallel edges between BB and SI blocks if (!UniqueSuccs.insert(SI).second) @@ -1583,7 +1584,7 @@ void BlockFrequencyInfoImpl::initTransitionProbabilities( auto EdgeProb = Scaled64::getFraction(EP.getNumerator(), EP.getDenominator()); - size_t Dst = BlockIndex.find(SI)->second; + size_t Dst = BlockIndexIt->second; Succs[Src].push_back(std::make_pair(Dst, EdgeProb)); SumProb[Src] += EdgeProb; }