Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic October 15, 2024 03:27
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Oct 15, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 15, 2024

@llvm/pr-subscribers-llvm-analysis

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/112297.diff

1 Files Affected:

  • (modified) llvm/include/llvm/Analysis/RegionInfoImpl.h (+4-7)
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();
 }

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazutakahirata kazutakahirata merged commit 5dca89c into llvm:main Oct 15, 2024
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_Analysis branch October 15, 2024 14:34
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:analysis Includes value tracking, cost tables and constant folding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants