[llvm] 2f88672 - [Coroutines] Avoid repeated hash lookups (NFC) (#126466)

via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 10 07:50:36 PST 2025


Author: Kazu Hirata
Date: 2025-02-10T07:50:32-08:00
New Revision: 2f88672414b4e9c74c47718c9979c79ba4c40e04

URL: https://github.com/llvm/llvm-project/commit/2f88672414b4e9c74c47718c9979c79ba4c40e04
DIFF: https://github.com/llvm/llvm-project/commit/2f88672414b4e9c74c47718c9979c79ba4c40e04.diff

LOG: [Coroutines] Avoid repeated hash lookups (NFC) (#126466)

Added: 
    

Modified: 
    llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp b/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp
index 3686c7c153999cb..5021425152f6cc0 100644
--- a/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp
+++ b/llvm/lib/Transforms/Coroutines/MaterializationUtils.cpp
@@ -70,11 +70,12 @@ struct RematGraph {
                std::deque<std::unique_ptr<RematNode>> &WorkList,
                User *FirstUse) {
     RematNode *N = NUPtr.get();
-    if (Remats.count(N->Node))
+    auto [It, Inserted] = Remats.try_emplace(N->Node);
+    if (!Inserted)
       return;
 
     // We haven't see this node yet - add to the list
-    Remats[N->Node] = std::move(NUPtr);
+    It->second = std::move(NUPtr);
     for (auto &Def : N->Node->operands()) {
       Instruction *D = dyn_cast<Instruction>(Def.get());
       if (!D || !MaterializableCallback(*D) ||


        


More information about the llvm-commits mailing list