Skip to content

Commit 80a4718

Browse files
[GVNHoist] Avoid repeated hash lookups (NFC) (llvm#126189)
1 parent dbb20fc commit 80a4718

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

llvm/lib/Transforms/Scalar/GVNHoist.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -564,21 +564,20 @@ unsigned int GVNHoist::rank(const Value *V) const {
564564
}
565565

566566
bool GVNHoist::hasEH(const BasicBlock *BB) {
567-
auto It = BBSideEffects.find(BB);
568-
if (It != BBSideEffects.end())
567+
auto [It, Inserted] = BBSideEffects.try_emplace(BB);
568+
if (!Inserted)
569569
return It->second;
570570

571571
if (BB->isEHPad() || BB->hasAddressTaken()) {
572-
BBSideEffects[BB] = true;
572+
It->second = true;
573573
return true;
574574
}
575575

576576
if (BB->getTerminator()->mayThrow()) {
577-
BBSideEffects[BB] = true;
577+
It->second = true;
578578
return true;
579579
}
580580

581-
BBSideEffects[BB] = false;
582581
return false;
583582
}
584583

0 commit comments

Comments
 (0)