[llvm] a5e969a - [CodeGen] Avoid repeated hash lookups (NFC) (#125382)

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 2 09:31:58 PST 2025


Author: Kazu Hirata
Date: 2025-02-02T09:31:55-08:00
New Revision: a5e969a82b6ec9e799235897973f83ae4f1e4245

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

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/InlineSpiller.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp
index cfd247e7c3caf6..302dd37ff3d67b 100644
--- a/llvm/lib/CodeGen/InlineSpiller.cpp
+++ b/llvm/lib/CodeGen/InlineSpiller.cpp
@@ -1532,10 +1532,12 @@ void HoistSpillHelper::runHoistSpills(
     MachineBasicBlock *Block = (*RIt)->getBlock();
 
     // If Block contains an original spill, simply continue.
-    if (SpillsToKeep.contains(*RIt) && !SpillsToKeep[*RIt]) {
-      SpillsInSubTreeMap[*RIt].first.insert(*RIt);
-      // SpillsInSubTreeMap[*RIt].second contains the cost of spill.
-      SpillsInSubTreeMap[*RIt].second = MBFI.getBlockFreq(Block);
+    if (auto It = SpillsToKeep.find(*RIt);
+        It != SpillsToKeep.end() && !It->second) {
+      auto &SIt = SpillsInSubTreeMap[*RIt];
+      SIt.first.insert(*RIt);
+      // Sit.second contains the cost of spill.
+      SIt.second = MBFI.getBlockFreq(Block);
       continue;
     }
 


        


More information about the llvm-commits mailing list