[PATCH] D53471: IR: make function getter compute hash once
Krasimir Georgiev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 20 00:46:46 PDT 2018
krasimir created this revision.
Herald added a subscriber: llvm-commits.
TODO: explain
Repository:
rL LLVM
https://reviews.llvm.org/D53471
Files:
lib/IR/Type.cpp
Index: lib/IR/Type.cpp
===================================================================
--- lib/IR/Type.cpp
+++ lib/IR/Type.cpp
@@ -297,20 +297,18 @@
FunctionType *FunctionType::get(Type *ReturnType,
ArrayRef<Type*> Params, bool isVarArg) {
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
- FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg);
- auto I = pImpl->FunctionTypes.find_as(Key);
+ const FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg);
FunctionType *FT;
-
- if (I == pImpl->FunctionTypes.end()) {
+ auto Insertion = pImpl->FunctionTypes.insert_as(nullptr, Key);
+ if (Insertion.second) {
FT = (FunctionType *)pImpl->TypeAllocator.Allocate(
sizeof(FunctionType) + sizeof(Type *) * (Params.size() + 1),
alignof(FunctionType));
new (FT) FunctionType(ReturnType, Params, isVarArg);
- pImpl->FunctionTypes.insert(FT);
+ *Insertion.first = FT;
} else {
- FT = *I;
+ FT = *Insertion.first;
}
-
return FT;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53471.170303.patch
Type: text/x-patch
Size: 1043 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181020/785993eb/attachment.bin>
More information about the llvm-commits
mailing list