Skip to content

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic February 10, 2025 05:28
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Feb 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 10, 2025

@llvm/pr-subscribers-llvm-analysis

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/include/llvm/Analysis/RegionInfoImpl.h (+3-5)
diff --git a/llvm/include/llvm/Analysis/RegionInfoImpl.h b/llvm/include/llvm/Analysis/RegionInfoImpl.h
index db3a9027549cefe..eb99d8bc6fb23ef 100644
--- a/llvm/include/llvm/Analysis/RegionInfoImpl.h
+++ b/llvm/include/llvm/Analysis/RegionInfoImpl.h
@@ -720,16 +720,14 @@ void RegionInfoBase<Tr>::buildRegionsTree(DomTreeNodeT *N, RegionT *region) {
   while (BB == region->getExit())
     region = region->getParent();
 
-  typename BBtoRegionMap::iterator it = BBtoRegion.find(BB);
+  auto [It, Inserted] = BBtoRegion.try_emplace(BB, region);
 
   // This basic block is a start block of a region. It is already in the
   // BBtoRegion relation. Only the child basic blocks have to be updated.
-  if (it != BBtoRegion.end()) {
-    RegionT *newRegion = it->second;
+  if (!Inserted) {
+    RegionT *newRegion = It->second;
     region->addSubRegion(getTopMostParent(newRegion));
     region = newRegion;
-  } else {
-    BBtoRegion[BB] = region;
   }
 
   for (DomTreeNodeBase<BlockT> *C : *N) {

@kazutakahirata kazutakahirata merged commit de56395 into llvm:main Feb 10, 2025
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_Analysis branch February 10, 2025 15:50
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
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