Skip to content

Commit 1904241

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (#132658)
1 parent 2edf534 commit 1904241

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/CodeGen/WinEHPrepare.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,12 @@ static void calculateCXXStateNumbers(WinEHFuncInfo &FuncInfo,
448448

449449
// It's possible for a cleanup to be visited twice: it might have multiple
450450
// cleanupret instructions.
451-
if (FuncInfo.EHPadStateMap.count(CleanupPad))
451+
auto [It, Inserted] = FuncInfo.EHPadStateMap.try_emplace(CleanupPad);
452+
if (!Inserted)
452453
return;
453454

454455
int CleanupState = addUnwindMapEntry(FuncInfo, ParentState, BB);
455-
FuncInfo.EHPadStateMap[CleanupPad] = CleanupState;
456+
It->second = CleanupState;
456457
LLVM_DEBUG(dbgs() << "Assigning state #" << CleanupState << " to BB "
457458
<< BB->getName() << '\n');
458459
for (const BasicBlock *PredBlock : predecessors(BB)) {
@@ -554,11 +555,12 @@ static void calculateSEHStateNumbers(WinEHFuncInfo &FuncInfo,
554555

555556
// It's possible for a cleanup to be visited twice: it might have multiple
556557
// cleanupret instructions.
557-
if (FuncInfo.EHPadStateMap.count(CleanupPad))
558+
auto [It, Inserted] = FuncInfo.EHPadStateMap.try_emplace(CleanupPad);
559+
if (!Inserted)
558560
return;
559561

560562
int CleanupState = addSEHFinally(FuncInfo, ParentState, BB);
561-
FuncInfo.EHPadStateMap[CleanupPad] = CleanupState;
563+
It->second = CleanupState;
562564
LLVM_DEBUG(dbgs() << "Assigning state #" << CleanupState << " to BB "
563565
<< BB->getName() << '\n');
564566
for (const BasicBlock *PredBlock : predecessors(BB))

0 commit comments

Comments
 (0)