Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic March 2, 2025 04:46
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Mar 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 2, 2025

@llvm/pr-subscribers-llvm-analysis

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/129417.diff

1 Files Affected:

  • (modified) llvm/lib/Analysis/ProfileSummaryInfo.cpp (+4-5)
diff --git a/llvm/lib/Analysis/ProfileSummaryInfo.cpp b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
index fdad14571dfe4..1a6d2006202bc 100644
--- a/llvm/lib/Analysis/ProfileSummaryInfo.cpp
+++ b/llvm/lib/Analysis/ProfileSummaryInfo.cpp
@@ -141,15 +141,14 @@ std::optional<uint64_t>
 ProfileSummaryInfo::computeThreshold(int PercentileCutoff) const {
   if (!hasProfileSummary())
     return std::nullopt;
-  auto iter = ThresholdCache.find(PercentileCutoff);
-  if (iter != ThresholdCache.end()) {
-    return iter->second;
-  }
+  auto [Iter, Inserted] = ThresholdCache.try_emplace(PercentileCutoff);
+  if (!Inserted)
+    return Iter->second;
   auto &DetailedSummary = Summary->getDetailedSummary();
   auto &Entry = ProfileSummaryBuilder::getEntryForPercentile(DetailedSummary,
                                                              PercentileCutoff);
   uint64_t CountThreshold = Entry.MinCount;
-  ThresholdCache[PercentileCutoff] = CountThreshold;
+  Iter->second = CountThreshold;
   return CountThreshold;
 }
 

@kazutakahirata kazutakahirata merged commit 69c7336 into llvm:main Mar 2, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_Analysis branch March 2, 2025 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:analysis Includes value tracking, cost tables and constant folding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants