Skip to content

[llvm-profgen] Avoid repeated hash lookups (NFC) #127028

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

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic February 13, 2025 08:07
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Feb 13, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 13, 2025

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/tools/llvm-profgen/MissingFrameInferrer.cpp (+4-3)
diff --git a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
index eefe38cd3fa00..ac88fced9159c 100644
--- a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
+++ b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
@@ -238,12 +238,13 @@ bool MissingFrameInferrer::inferMissingFrames(
     return false;
 
   // Bail out if caller has no known outgoing call edges.
-  if (!CallEdgesF.count(From))
+  auto It = CallEdgesF.find(From);
+  if (It == CallEdgesF.end())
     return false;
 
   // Done with the inference if the calle is reachable via a single callsite.
   // This may not be accurate but it improves the search throughput.
-  if (llvm::is_contained(CallEdgesF[From], ToFRange->Func))
+  if (llvm::is_contained(It->second, ToFRange->Func))
     return true;
 
   // Bail out if callee is not tailcall reachable at all.
@@ -253,7 +254,7 @@ bool MissingFrameInferrer::inferMissingFrames(
   Visiting.clear();
   CurSearchingDepth = 0;
   uint64_t NumPaths = 0;
-  for (auto Target : CallEdgesF[From]) {
+  for (auto Target : It->second) {
     NumPaths +=
         computeUniqueTailCallPath(Target, ToFRange->Func, UniquePath);
     // Stop analyzing the remaining if we are already seeing more than one

@kazutakahirata kazutakahirata merged commit 4bda953 into llvm:main Feb 13, 2025
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_profgen branch February 13, 2025 17:12
joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
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