Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic March 1, 2025 04:12
@llvmbot llvmbot added PGO Profile Guided Optimizations llvm:transforms labels Mar 1, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 1, 2025

@llvm/pr-subscribers-pgo

@llvm/pr-subscribers-llvm-transforms

Author: Kazu Hirata (kazutakahirata)

Changes

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

1 Files Affected:

  • (modified) llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h (+3-4)
diff --git a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
index 390f284019bb4..d714dba4a9687 100644
--- a/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
+++ b/llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h
@@ -646,14 +646,13 @@ void SampleProfileLoaderBaseImpl<BT>::findEquivalenceClasses(FunctionT &F) {
     BasicBlockT *BB1 = &BB;
 
     // Compute BB1's equivalence class once.
-    if (EquivalenceClass.count(BB1)) {
+    // By default, blocks are in their own equivalence class.
+    auto [It, Inserted] = EquivalenceClass.try_emplace(BB1, BB1);
+    if (!Inserted) {
       LLVM_DEBUG(printBlockEquivalence(dbgs(), BB1));
       continue;
     }
 
-    // By default, blocks are in their own equivalence class.
-    EquivalenceClass[BB1] = BB1;
-
     // Traverse all the blocks dominated by BB1. We are looking for
     // every basic block BB2 such that:
     //

@kazutakahirata kazutakahirata merged commit f892dc7 into llvm:main Mar 1, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_Utils branch March 1, 2025 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:transforms PGO Profile Guided Optimizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants