[llvm] [Analysis] Avoid repeated hash lookups (NFC) (PR #110397)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 28 19:50:50 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/110397
>From 5065e286fa050725a8b7c33a09ad4942c58cdc5a Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 28 Sep 2024 13:17:38 -0700
Subject: [PATCH] [Analysis] Avoid repeated hash lookups (NFC)
---
llvm/lib/Analysis/InlineCost.cpp | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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