[llvm] 8a9e9a8 - [Analysis] Avoid repeated hash lookups (NFC) (#110397)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 29 08:50:40 PDT 2024


Author: Kazu Hirata
Date: 2024-09-29T08:50:37-07:00
New Revision: 8a9e9a89f0f5d58d1dacf3a7e626d8eb1c4ea485

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

LOG: [Analysis] Avoid repeated hash lookups (NFC) (#110397)

Added: 
    

Modified: 
    llvm/lib/Analysis/InlineCost.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 4b65fa0ae41b2f..d2c329ba748e58 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -504,8 +504,9 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
   InlineResult analyze();
 
   std::optional<Constant *> getSimplifiedValue(Instruction *I) {
-    if (SimplifiedValues.contains(I))
-      return SimplifiedValues[I];
+    auto It = SimplifiedValues.find(I);
+    if (It != SimplifiedValues.end())
+      return It->second;
     return std::nullopt;
   }
 
@@ -1129,8 +1130,9 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
   void print(raw_ostream &OS);
 
   std::optional<InstructionCostDetail> getCostDetails(const Instruction *I) {
-    if (InstructionCostDetailMap.contains(I))
-      return InstructionCostDetailMap[I];
+    auto It = InstructionCostDetailMap.find(I);
+    if (It != InstructionCostDetailMap.end())
+      return It->second;
     return std::nullopt;
   }
 


        


More information about the llvm-commits mailing list