Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Feb 20, 2025

@llvm/pr-subscribers-backend-webassembly

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp (+9-9)
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp b/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp
index cd84e68aed140..0469fbf15b251 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblySortRegion.cpp
@@ -28,17 +28,17 @@ const SortRegion *SortRegionInfo::getRegionFor(const MachineBasicBlock *MBB) {
   // WE->contains(ML->getHeader()), but not ML->contains(WE->getHeader()).
   if ((ML && !WE) || (ML && WE && WE->contains(ML->getHeader()))) {
     // If the smallest region containing MBB is a loop
-    if (LoopMap.count(ML))
-      return LoopMap[ML].get();
-    LoopMap[ML] = std::make_unique<ConcreteSortRegion<MachineLoop>>(ML);
-    return LoopMap[ML].get();
+    auto [It, Inserted] = LoopMap.try_emplace(ML);
+    if (Inserted)
+      It->second = std::make_unique<ConcreteSortRegion<MachineLoop>>(ML);
+    return It->second.get();
   } else {
     // If the smallest region containing MBB is an exception
-    if (ExceptionMap.count(WE))
-      return ExceptionMap[WE].get();
-    ExceptionMap[WE] =
-        std::make_unique<ConcreteSortRegion<WebAssemblyException>>(WE);
-    return ExceptionMap[WE].get();
+    auto [It, Inserted] = ExceptionMap.try_emplace(WE);
+    if (Inserted)
+      It->second =
+          std::make_unique<ConcreteSortRegion<WebAssemblyException>>(WE);
+    return It->second.get();
   }
 }
 

@kazutakahirata kazutakahirata merged commit be51ef4 into llvm:main Feb 20, 2025
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_WebAssembly branch February 20, 2025 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants