Skip to content

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

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 10, 2025 05:29
@llvmbot llvmbot added the PGO Profile Guided Optimizations label Feb 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 10, 2025

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/tools/llvm-profgen/MissingFrameInferrer.cpp (+3-2)
diff --git a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
index ee49950f39ca4e2..eefe38cd3fa0025 100644
--- a/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
+++ b/llvm/tools/llvm-profgen/MissingFrameInferrer.cpp
@@ -206,11 +206,12 @@ uint64_t MissingFrameInferrer::computeUniqueTailCallPath(
 
 uint64_t MissingFrameInferrer::computeUniqueTailCallPath(
     uint64_t From, BinaryFunction *To, SmallVectorImpl<uint64_t> &Path) {
-  if (!TailCallEdgesF.count(From))
+  auto It = TailCallEdgesF.find(From);
+  if (It == TailCallEdgesF.end())
     return 0;
   Path.push_back(From);
   uint64_t NumPaths = 0;
-  for (auto Target : TailCallEdgesF[From]) {
+  for (auto Target : It->second) {
     NumPaths += computeUniqueTailCallPath(Target, To, Path);
     // Stop analyzing the remaining if we are already seeing more than one
     // reachable paths.

@kazutakahirata kazutakahirata merged commit 6228379 into llvm:main Feb 10, 2025
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_profgen branch February 10, 2025 15:51
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 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