Skip to content

Commit de56395

Browse files
[Analysis] Avoid repeated hash lookups (NFC) (#126465)
1 parent ba9810e commit de56395

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/include/llvm/Analysis/RegionInfoImpl.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -720,16 +720,14 @@ void RegionInfoBase<Tr>::buildRegionsTree(DomTreeNodeT *N, RegionT *region) {
720720
while (BB == region->getExit())
721721
region = region->getParent();
722722

723-
typename BBtoRegionMap::iterator it = BBtoRegion.find(BB);
723+
auto [It, Inserted] = BBtoRegion.try_emplace(BB, region);
724724

725725
// This basic block is a start block of a region. It is already in the
726726
// BBtoRegion relation. Only the child basic blocks have to be updated.
727-
if (it != BBtoRegion.end()) {
728-
RegionT *newRegion = it->second;
727+
if (!Inserted) {
728+
RegionT *newRegion = It->second;
729729
region->addSubRegion(getTopMostParent(newRegion));
730730
region = newRegion;
731-
} else {
732-
BBtoRegion[BB] = region;
733731
}
734732

735733
for (DomTreeNodeBase<BlockT> *C : *N) {

0 commit comments

Comments
 (0)