[llvm] [Scalar] Avoid repeated hash lookups (NFC) (PR #126189)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 6 22:51:34 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/126189
None
>From 2be758535a6b217bb244358c69ed9d1d09a28e09 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
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 c6f015112e59df1..1c2e1531e47d882 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;
}
More information about the llvm-commits
mailing list