Skip to content

Commit af922cf

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (llvm#127745)
1 parent c23256e commit af922cf

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

llvm/lib/CodeGen/WinEHPrepare.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,15 @@ void llvm::calculateCXXStateForAsynchEH(const BasicBlock *BB, int State,
251251
const BasicBlock *BB = WI->Block;
252252
int State = WI->State;
253253
delete WI;
254-
if (auto It = EHInfo.BlockToStateMap.find(BB);
255-
It != EHInfo.BlockToStateMap.end() && It->second <= State)
254+
auto [StateIt, Inserted] = EHInfo.BlockToStateMap.try_emplace(BB);
255+
if (!Inserted && StateIt->second <= State)
256256
continue; // skip blocks already visited by lower State
257257

258258
BasicBlock::const_iterator It = BB->getFirstNonPHIIt();
259259
const llvm::Instruction *TI = BB->getTerminator();
260260
if (It->isEHPad())
261261
State = EHInfo.EHPadStateMap[&*It];
262-
EHInfo.BlockToStateMap[BB] = State; // Record state, also flag visiting
262+
StateIt->second = State; // Record state, also flag visiting
263263

264264
if ((isa<CleanupReturnInst>(TI) || isa<CatchReturnInst>(TI)) && State > 0) {
265265
// Retrive the new State

0 commit comments

Comments
 (0)