From 5053ef42d62f9805c308b52dba7b5efba9d39a42 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 6 Mar 2025 08:58:03 -0800 Subject: [PATCH] [Analysis] Avoid repeated hash lookups (NFC) --- llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; }