From 59e3653b83c4b5b33f5dae31319d478f1c50cbcc Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 21 Mar 2025 08:36:55 -0700 Subject: [PATCH] [SPIRV] Avoid repeated hash lookups (NFC) --- llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp b/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp index 2632e0ad546ef..a956fad5487c1 100644 --- a/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp +++ b/llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp @@ -197,7 +197,8 @@ void SPIRVRegularizer::visitCallScalToVec(CallInst *CI, StringRef MangledName, auto *OldF = CI->getCalledFunction(); Function *NewF = nullptr; - if (!Old2NewFuncs.count(OldF)) { + auto [It, Inserted] = Old2NewFuncs.try_emplace(OldF); + if (Inserted) { AttributeList Attrs = CI->getCalledFunction()->getAttributes(); SmallVector ArgTypes = {OldF->getArg(0)->getType(), Arg0Ty}; auto *NewFTy = @@ -215,9 +216,9 @@ void SPIRVRegularizer::visitCallScalToVec(CallInst *CI, StringRef MangledName, CloneFunctionInto(NewF, OldF, VMap, CloneFunctionChangeType::LocalChangesOnly, Returns); NewF->setAttributes(Attrs); - Old2NewFuncs[OldF] = NewF; + It->second = NewF; } else { - NewF = Old2NewFuncs[OldF]; + NewF = It->second; } assert(NewF);