Skip to content

Commit 5471810

Browse files
[SPIRV] Avoid repeated hash lookups (NFC) (#132515)
1 parent d8d2e7c commit 5471810

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Target/SPIRV/SPIRVRegularizer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ void SPIRVRegularizer::visitCallScalToVec(CallInst *CI, StringRef MangledName,
197197

198198
auto *OldF = CI->getCalledFunction();
199199
Function *NewF = nullptr;
200-
if (!Old2NewFuncs.count(OldF)) {
200+
auto [It, Inserted] = Old2NewFuncs.try_emplace(OldF);
201+
if (Inserted) {
201202
AttributeList Attrs = CI->getCalledFunction()->getAttributes();
202203
SmallVector<Type *, 2> ArgTypes = {OldF->getArg(0)->getType(), Arg0Ty};
203204
auto *NewFTy =
@@ -215,9 +216,9 @@ void SPIRVRegularizer::visitCallScalToVec(CallInst *CI, StringRef MangledName,
215216
CloneFunctionInto(NewF, OldF, VMap,
216217
CloneFunctionChangeType::LocalChangesOnly, Returns);
217218
NewF->setAttributes(Attrs);
218-
Old2NewFuncs[OldF] = NewF;
219+
It->second = NewF;
219220
} else {
220-
NewF = Old2NewFuncs[OldF];
221+
NewF = It->second;
221222
}
222223
assert(NewF);
223224

0 commit comments

Comments
 (0)