From 2be758535a6b217bb244358c69ed9d1d09a28e09 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Thu, 6 Feb 2025 16:10:11 -0800 Subject: [PATCH] [Scalar] Avoid repeated hash lookups (NFC) --- llvm/lib/Transforms/Scalar/GVNHoist.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/GVNHoist.cpp b/llvm/lib/Transforms/Scalar/GVNHoist.cpp index c6f015112e59d..1c2e1531e47d8 100644 --- a/llvm/lib/Transforms/Scalar/GVNHoist.cpp +++ b/llvm/lib/Transforms/Scalar/GVNHoist.cpp @@ -564,21 +564,20 @@ unsigned int GVNHoist::rank(const Value *V) const { } bool GVNHoist::hasEH(const BasicBlock *BB) { - auto It = BBSideEffects.find(BB); - if (It != BBSideEffects.end()) + auto [It, Inserted] = BBSideEffects.try_emplace(BB); + if (!Inserted) return It->second; if (BB->isEHPad() || BB->hasAddressTaken()) { - BBSideEffects[BB] = true; + It->second = true; return true; } if (BB->getTerminator()->mayThrow()) { - BBSideEffects[BB] = true; + It->second = true; return true; } - BBSideEffects[BB] = false; return false; }