[llvm] 915fe84 - [ctx_prof] Simplify ingestContext (NFC) (#109902)

via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 22:53:20 PDT 2024


Author: Kazu Hirata
Date: 2024-09-24T22:53:16-07:00
New Revision: 915fe84c6d78f3c0268f3de571eb323304089d23

URL: https://github.com/llvm/llvm-project/commit/915fe84c6d78f3c0268f3de571eb323304089d23
DIFF: https://github.com/llvm/llvm-project/commit/915fe84c6d78f3c0268f3de571eb323304089d23.diff

LOG: [ctx_prof] Simplify ingestContext (NFC) (#109902)

try_emplace can default-construct the value, so:

  try_emplace(CSId, CallTargetMapTy())
  try_emplace(CSId)

are equivalent to each other.  We can further simplify the function
using the fact that Map.try_emplace(Key).first->second is the same as
Map[Key].

Added: 
    

Modified: 
    llvm/include/llvm/ProfileData/PGOCtxProfReader.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
index beda07d7b8286c..a00c21ddc7d7a1 100644
--- a/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
+++ b/llvm/include/llvm/ProfileData/PGOCtxProfReader.h
@@ -68,8 +68,7 @@ class PGOCtxProfContext final {
   CallsiteMapTy &callsites() { return Callsites; }
 
   void ingestContext(uint32_t CSId, PGOCtxProfContext &&Other) {
-    auto [Iter, _] = callsites().try_emplace(CSId, CallTargetMapTy());
-    Iter->second.emplace(Other.guid(), std::move(Other));
+    callsites()[CSId].emplace(Other.guid(), std::move(Other));
   }
 
   void ingestAllContexts(uint32_t CSId, CallTargetMapTy &&Other) {


        


More information about the llvm-commits mailing list