[llvm] 44b9f5e - [CodeGen] Avoid repeated hash lookups (NFC) (#129190)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 23:01:38 PST 2025


Author: Kazu Hirata
Date: 2025-02-27T23:01:35-08:00
New Revision: 44b9f5eeab63dbf7d4e4ebc87dfedca5c42708b6

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

LOG: [CodeGen] Avoid repeated hash lookups (NFC) (#129190)

Added: 
    

Modified: 
    llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
index dbc724629d3be..8d91e7119d0ba 100644
--- a/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ b/llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -600,12 +600,12 @@ class MemLocFragmentFill {
         break;
     }
 
-    auto CurrentLiveInEntry = LiveIn.find(&BB);
     // If there's no LiveIn entry for the block yet, add it.
-    if (CurrentLiveInEntry == LiveIn.end()) {
+    auto [CurrentLiveInEntry, Inserted] = LiveIn.try_emplace(&BB);
+    if (Inserted) {
       LLVM_DEBUG(dbgs() << "change=true (first) on meet on " << BB.getName()
                         << "\n");
-      LiveIn[&BB] = std::move(BBLiveIn);
+      CurrentLiveInEntry->second = std::move(BBLiveIn);
       return /*Changed=*/true;
     }
 


        


More information about the llvm-commits mailing list