From 3859b1a50f57114db8b5dbe44676ef2e77c48f07 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 21 Mar 2025 08:32:08 -0700 Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC) --- llvm/lib/CodeGen/GCMetadata.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/GCMetadata.cpp b/llvm/lib/CodeGen/GCMetadata.cpp index f33008c9e0f23..fa87b14e708e1 100644 --- a/llvm/lib/CodeGen/GCMetadata.cpp +++ b/llvm/lib/CodeGen/GCMetadata.cpp @@ -41,8 +41,10 @@ CollectorMetadataAnalysis::run(Module &M, ModuleAnalysisManager &MAM) { for (auto &F : M) { if (F.isDeclaration() || !F.hasGC()) continue; - if (auto GCName = F.getGC(); !Map.contains(GCName)) - Map[GCName] = getGCStrategy(GCName); + auto GCName = F.getGC(); + auto [It, Inserted] = Map.try_emplace(GCName); + if (Inserted) + It->second = getGCStrategy(GCName); } return R; }