[llvm] [IPO] Simplify code with StringMap::operator[] (NFC) (PR #112490)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 00:14:41 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/112490

None

>From 24f798aaa0846ba225db8f1c9efd24f1550f222b Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 16 Oct 2024 00:10:47 -0700
Subject: [PATCH] [IPO] Simplify code with StringMap::operator[] (NFC)

---
 llvm/include/llvm/Transforms/IPO/SampleProfileMatcher.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/llvm/include/llvm/Transforms/IPO/SampleProfileMatcher.h b/llvm/include/llvm/Transforms/IPO/SampleProfileMatcher.h
index 076d91adfd1dea..4e757b29961817 100644
--- a/llvm/include/llvm/Transforms/IPO/SampleProfileMatcher.h
+++ b/llvm/include/llvm/Transforms/IPO/SampleProfileMatcher.h
@@ -201,9 +201,7 @@ class SampleProfileMatcher {
   void UpdateWithSalvagedProfiles();
 
   LocToLocMap &getIRToProfileLocationMap(const Function &F) {
-    auto Ret = FuncMappings.try_emplace(
-        FunctionSamples::getCanonicalFnName(F.getName()), LocToLocMap());
-    return Ret.first->second;
+    return FuncMappings[FunctionSamples::getCanonicalFnName(F.getName())];
   }
   void distributeIRToProfileLocationMap();
   void distributeIRToProfileLocationMap(FunctionSamples &FS);



More information about the llvm-commits mailing list