[llvm] 3d15bfb - [CodeGen] Avoid repeated hash lookups (NFC) (#123500)

via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 19 10:57:28 PST 2025


Author: Kazu Hirata
Date: 2025-01-19T10:57:25-08:00
New Revision: 3d15bfb40c14233a479439eb98f0318d1795b02a

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

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp b/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
index 0ebe845e473fd6..edb85d212a4d48 100644
--- a/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
+++ b/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp
@@ -190,7 +190,8 @@ class RegReloadCache {
   // Does basic block MBB contains reload of Reg from FI?
   bool hasReload(Register Reg, int FI, const MachineBasicBlock *MBB) {
     RegSlotPair RSP(Reg, FI);
-    return Reloads.count(MBB) && Reloads[MBB].count(RSP);
+    auto It = Reloads.find(MBB);
+    return It != Reloads.end() && It->second.count(RSP);
   }
 };
 
@@ -242,9 +243,10 @@ class FrameIndexesCache {
       It.second.Index = 0;
 
     ReservedSlots.clear();
-    if (EHPad && GlobalIndices.count(EHPad))
-      for (auto &RSP : GlobalIndices[EHPad])
-        ReservedSlots.insert(RSP.second);
+    if (EHPad)
+      if (auto It = GlobalIndices.find(EHPad); It != GlobalIndices.end())
+        for (auto &RSP : It->second)
+          ReservedSlots.insert(RSP.second);
   }
 
   // Get frame index to spill the register.


        


More information about the llvm-commits mailing list