Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Mar 22, 2025

@llvm/pr-subscribers-backend-spir-v

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/132515.diff

1 Files Affected:

  • (modified) llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp (+4-3)
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<Type *, 2> 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);
 

@kazutakahirata kazutakahirata merged commit 5471810 into llvm:main Mar 22, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_repeated_hash_lookups_llvm_SPIRV branch March 22, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants