Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ProfileData] Avoid repeated hash lookups (NFC) #129194

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic February 28, 2025 05:44
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Feb 28, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 28, 2025

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/ProfileData/InstrProfWriter.cpp (+3-2)
diff --git a/llvm/lib/ProfileData/InstrProfWriter.cpp b/llvm/lib/ProfileData/InstrProfWriter.cpp
index f112ea2efcaa9..18aa76c865bc8 100644
--- a/llvm/lib/ProfileData/InstrProfWriter.cpp
+++ b/llvm/lib/ProfileData/InstrProfWriter.cpp
@@ -230,7 +230,8 @@ void InstrProfWriter::overlapRecord(NamedInstrProfRecord &&Other,
   auto Name = Other.Name;
   auto Hash = Other.Hash;
   Other.accumulateCounts(FuncLevelOverlap.Test);
-  if (!FunctionData.contains(Name)) {
+  auto It = FunctionData.find(Name);
+  if (It == FunctionData.end()) {
     Overlap.addOneUnique(FuncLevelOverlap.Test);
     return;
   }
@@ -238,7 +239,7 @@ void InstrProfWriter::overlapRecord(NamedInstrProfRecord &&Other,
     Overlap.Overlap.NumEntries += 1;
     return;
   }
-  auto &ProfileDataMap = FunctionData[Name];
+  auto &ProfileDataMap = It->second;
   bool NewFunc;
   ProfilingData::iterator Where;
   std::tie(Where, NewFunc) =

@kazutakahirata kazutakahirata merged commit 192b13b into llvm:main Feb 28, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_ProfileData branch February 28, 2025 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PGO Profile Guided Optimizations
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants