[llvm] ecccc6a - [Coroutines] Avoid repeated hash lookps (NFC) (#110076)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 07:59:27 PDT 2024


Author: Kazu Hirata
Date: 2024-09-26T07:59:24-07:00
New Revision: ecccc6a350e83bb8f776e2599b5cdc5e38591894

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

LOG: [Coroutines] Avoid repeated hash lookps (NFC) (#110076)

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Coroutines/SpillUtils.cpp b/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
index f213ac1c8d7d57..96b5c8440e5f9a 100644
--- a/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
+++ b/llvm/lib/Transforms/Coroutines/SpillUtils.cpp
@@ -397,13 +397,11 @@ struct AllocaUseVisitor : PtrUseVisitor<AllocaUseVisitor> {
     if (!IsOffsetKnown) {
       AliasOffetMap[&I].reset();
     } else {
-      auto Itr = AliasOffetMap.find(&I);
-      if (Itr == AliasOffetMap.end()) {
-        AliasOffetMap[&I] = Offset;
-      } else if (Itr->second && *Itr->second != Offset) {
+      auto [Itr, Inserted] = AliasOffetMap.try_emplace(&I, Offset);
+      if (!Inserted && Itr->second && *Itr->second != Offset) {
         // If we have seen two 
diff erent possible values for this alias, we set
         // it to empty.
-        AliasOffetMap[&I].reset();
+        Itr->second.reset();
       }
     }
   }


        


More information about the llvm-commits mailing list