From 57f97378666838bbb2cdba4e0f80ed44c96a7246 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Tue, 18 Feb 2025 09:45:42 -0800 Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC) --- llvm/lib/CodeGen/WinEHPrepare.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index b98523cac1f2f..1970716485613 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -251,15 +251,15 @@ void llvm::calculateCXXStateForAsynchEH(const BasicBlock *BB, int State, const BasicBlock *BB = WI->Block; int State = WI->State; delete WI; - if (auto It = EHInfo.BlockToStateMap.find(BB); - It != EHInfo.BlockToStateMap.end() && It->second <= State) + auto [StateIt, Inserted] = EHInfo.BlockToStateMap.try_emplace(BB); + if (!Inserted && StateIt->second <= State) continue; // skip blocks already visited by lower State BasicBlock::const_iterator It = BB->getFirstNonPHIIt(); const llvm::Instruction *TI = BB->getTerminator(); if (It->isEHPad()) State = EHInfo.EHPadStateMap[&*It]; - EHInfo.BlockToStateMap[BB] = State; // Record state, also flag visiting + StateIt->second = State; // Record state, also flag visiting if ((isa(TI) || isa(TI)) && State > 0) { // Retrive the new State