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

[IPO] Avoid repeated map lookups (NFC) #132144

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 20, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/SampleContextTracker.cpp (+3-2)
diff --git a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp
index 270ca56d04823..c8f203e8ce3ee 100644
--- a/llvm/lib/Transforms/IPO/SampleContextTracker.cpp
+++ b/llvm/lib/Transforms/IPO/SampleContextTracker.cpp
@@ -189,8 +189,9 @@ ContextTrieNode *ContextTrieNode::getOrCreateChildContext(
   if (!AllowCreate)
     return nullptr;
 
-  AllChildContext[Hash] = ContextTrieNode(this, CalleeName, nullptr, CallSite);
-  return &AllChildContext[Hash];
+  ContextTrieNode &ACC = AllChildContext[Hash];
+  ACC = ContextTrieNode(this, CalleeName, nullptr, CallSite);
+  return &ACC;
 }
 
 // Profiler tracker than manages profiles and its associated context

@kazutakahirata kazutakahirata merged commit bc9cee1 into llvm:main Mar 20, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_IPO branch March 20, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants