[PATCH] D144910: [LLVMContextImpl] Separate out opaque pointers
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 27 13:19:16 PST 2023
aeubanks created this revision.
aeubanks added a reviewer: nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
To make the map lookups simpler for opaque pointers and to simplify future typed pointer code removal. No significant compile time wins though.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D144910
Files:
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/IR/Type.cpp
Index: llvm/lib/IR/Type.cpp
===================================================================
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -749,8 +749,10 @@
return get(EltTy->getContext(), AddressSpace);
// Since AddressSpace #0 is the common case, we special case it.
- PointerType *&Entry = AddressSpace == 0 ? CImpl->PointerTypes[EltTy]
- : CImpl->ASPointerTypes[std::make_pair(EltTy, AddressSpace)];
+ PointerType *&Entry =
+ AddressSpace == 0
+ ? CImpl->LegacyPointerTypes[EltTy]
+ : CImpl->LegacyASPointerTypes[std::make_pair(EltTy, AddressSpace)];
if (!Entry)
Entry = new (CImpl->Alloc) PointerType(EltTy, AddressSpace);
@@ -763,10 +765,8 @@
"Can only create opaque pointers in opaque pointer mode");
// Since AddressSpace #0 is the common case, we special case it.
- PointerType *&Entry =
- AddressSpace == 0
- ? CImpl->PointerTypes[nullptr]
- : CImpl->ASPointerTypes[std::make_pair(nullptr, AddressSpace)];
+ PointerType *&Entry = AddressSpace == 0 ? CImpl->AS0PointerType
+ : CImpl->PointerTypes[AddressSpace];
if (!Entry)
Entry = new (CImpl->Alloc) PointerType(C, AddressSpace);
Index: llvm/lib/IR/LLVMContextImpl.h
===================================================================
--- llvm/lib/IR/LLVMContextImpl.h
+++ llvm/lib/IR/LLVMContextImpl.h
@@ -1535,8 +1535,11 @@
DenseMap<std::pair<Type *, uint64_t>, ArrayType *> ArrayTypes;
DenseMap<std::pair<Type *, ElementCount>, VectorType *> VectorTypes;
- DenseMap<Type *, PointerType *> PointerTypes; // Pointers in AddrSpace = 0
- DenseMap<std::pair<Type *, unsigned>, PointerType *> ASPointerTypes;
+ PointerType *AS0PointerType = nullptr; // AddrSpace = 0
+ DenseMap<unsigned, PointerType *> PointerTypes;
+ DenseMap<Type *, PointerType *>
+ LegacyPointerTypes; // Pointers in AddrSpace = 0
+ DenseMap<std::pair<Type *, unsigned>, PointerType *> LegacyASPointerTypes;
DenseMap<std::pair<Type *, unsigned>, TypedPointerType *> ASTypedPointerTypes;
/// ValueHandles - This map keeps track of all of the value handles that are
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144910.500894.patch
Type: text/x-patch
Size: 2169 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230227/97482f11/attachment.bin>
More information about the llvm-commits
mailing list