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::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: //