[llvm-dev] [RFC] Introducing the opaque pointer type
Arthur Eubanks via llvm-dev
llvm-dev at lists.llvm.org
Mon May 3 17:38:41 PDT 2021
For background on opaque pointer types, see  and many other
patches/threads searchable with "opaque pointers".
While there's been lots of work around making opaque pointers work, we
don't actually have a type like that in LLVM yet.
https://reviews.llvm.org/D101704 introduces the opaque pointer type within
LLVM so we can start playing around with the opaque pointer type and see
what goes wrong. Much of the patch above is based on TNorthover's branch
from a couple years ago .
The opaque pointer type is essentially just a PointerType with a null
pointee type. Calling getElementType() on an opaque pointer asserts.
Since the bitcode representation for non-opaque pointers contains the
pointee type, we need a new bitcode type code for opaque pointers, which
only contains the address space.
For the textual IR representation, the current proposal is to represent an
opaque pointer type with "ptr" with an optional "addrspace(N)". This seems
consistent with existing uses of "addrspace(N)" and "ptr" seems right.
There are a couple alternatives. TNorthover's version uses "pN" where "N"
is the address space, so most pointers would be "p0", and a pointer in
address space #5 would be "p5". I initially attempted something like
"ptr(N)", but the spelling is slightly ambiguous with function types. We
could also simply use a void pointer, which LLVM currently does not allow
Feel free to bikeshed.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev