Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 16, 2025

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/lib/Transforms/IPO/FunctionAttrs.cpp (+5-6)
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 1fca1b54065d4..f70686bc57ee4 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -319,8 +319,8 @@ static FunctionSummary *calculatePrevailingSummary(
     function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
         IsPrevailing) {
 
-  if (auto It = CachedPrevailingSummary.find(VI);
-      It != CachedPrevailingSummary.end())
+  auto [It, Inserted] = CachedPrevailingSummary.try_emplace(VI);
+  if (!Inserted)
     return It->second;
 
   /// At this point, prevailing symbols have been resolved. The following leads
@@ -363,7 +363,6 @@ static FunctionSummary *calculatePrevailingSummary(
   ///      future this can be revisited.
   ///   5. Otherwise, go conservative.
 
-  CachedPrevailingSummary[VI] = nullptr;
   FunctionSummary *Local = nullptr;
   FunctionSummary *Prevailing = nullptr;
 
@@ -764,12 +763,12 @@ ArgumentUsesSummary collectArgumentUsesPerBlock(Argument &A, Function &F) {
   auto UpdateUseInfo = [&Result](Instruction *I, ArgumentAccessInfo Info) {
     auto *BB = I->getParent();
     auto &BBInfo = Result.UsesPerBlock[BB];
-    bool AlreadyVisitedInst = BBInfo.Insts.contains(I);
-    auto &IInfo = BBInfo.Insts[I];
+    auto [It, Inserted] = BBInfo.Insts.try_emplace(I);
+    auto &IInfo = It->second;
 
     // Instructions that have more than one use of the argument are considered
     // as clobbers.
-    if (AlreadyVisitedInst) {
+    if (!Inserted) {
       IInfo = {ArgumentAccessInfo::AccessType::Unknown, {}};
       BBInfo.HasUnknownAccess = true;
       return false;

@kazutakahirata kazutakahirata merged commit 1bc2108 into llvm:main Mar 16, 2025
13 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_IPO branch March 16, 2025 16:30
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