From e9e706274f04cf7ab4cebb10603b56910a316e10 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 27 Feb 2025 23:04:13 -0800 Subject: [PATCH] [Transforms] Avoid repeated hash lookups (NFC) --- .../llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h index 390f284019bb4..d714dba4a9687 100644 --- a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h +++ b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h @@ -646,14 +646,13 @@ void SampleProfileLoaderBaseImpl::findEquivalenceClasses(FunctionT &F) { BasicBlockT *BB1 = &BB; // Compute BB1's equivalence class once. - if (EquivalenceClass.count(BB1)) { + // By default, blocks are in their own equivalence class. + auto [It, Inserted] = EquivalenceClass.try_emplace(BB1, BB1); + if (!Inserted) { LLVM_DEBUG(printBlockEquivalence(dbgs(), BB1)); continue; } - // By default, blocks are in their own equivalence class. - EquivalenceClass[BB1] = BB1; - // Traverse all the blocks dominated by BB1. We are looking for // every basic block BB2 such that: //