[llvm] 5dca89c - [Analysis] Avoid repeated hash lookups (NFC) (#112297)

via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 07:34:24 PDT 2024


Author: Kazu Hirata
Date: 2024-10-15T07:34:20-07:00
New Revision: 5dca89c2d5ce30dfb3852122d8dc62915a1e449b

URL: https://github.com/llvm/llvm-project/commit/5dca89c2d5ce30dfb3852122d8dc62915a1e449b
DIFF: https://github.com/llvm/llvm-project/commit/5dca89c2d5ce30dfb3852122d8dc62915a1e449b.diff

LOG: [Analysis] Avoid repeated hash lookups (NFC) (#112297)

Added: 
    

Modified: 
    llvm/include/llvm/Analysis/RegionInfoImpl.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Analysis/RegionInfoImpl.h b/llvm/include/llvm/Analysis/RegionInfoImpl.h
index ebfb060ded3dd4..db3a9027549cef 100644
--- a/llvm/include/llvm/Analysis/RegionInfoImpl.h
+++ b/llvm/include/llvm/Analysis/RegionInfoImpl.h
@@ -338,14 +338,11 @@ template <class Tr>
 typename Tr::RegionNodeT *RegionBase<Tr>::getBBNode(BlockT *BB) const {
   assert(contains(BB) && "Can get BB node out of this region!");
 
-  typename BBNodeMapT::const_iterator at = BBNodeMap.find(BB);
-
-  if (at == BBNodeMap.end()) {
+  auto [at, Inserted] = BBNodeMap.try_emplace(BB);
+  if (Inserted) {
     auto Deconst = const_cast<RegionBase<Tr> *>(this);
-    typename BBNodeMapT::value_type V = {
-        BB,
-        std::make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB)};
-    at = BBNodeMap.insert(std::move(V)).first;
+    at->second =
+        std::make_unique<RegionNodeT>(static_cast<RegionT *>(Deconst), BB);
   }
   return at->second.get();
 }


        


More information about the llvm-commits mailing list