LLVM IR has introduced and is moving forward with the concept of opaque
pointers, i.e. pointer types that are not carrying around the pointee type.
Instead, memory-related operations indicate the type of the data being accessed
through the opaque pointer. Introduce the initial support for opaque pointers
in the LLVM dialect:
- LLVMPointerType to support omitting the element type;
- alloca/load/store/gep to support opaque pointers in their operands and results; this requires alloca and gep to store the element type as an attribute;
- memory-related intrinsics to support opaque pointers in their operands;
- translation to LLVM IR for the ops above is no longer using methods deprecated in LLVM API due to the introduction of opaque pointers.
Unlike LLVM IR, MLIR can afford to support both opaque and non-opaque pointers
at the same time and simplify the transition. Translation to LLVM IR of MLIR
that involves opaque pointers requires the LLVMContext to be configured to
always use opaque pointers.
Perhaps it's better to do the ternary before the getElementType? While this works for now, if for some reason opaque pointers mean LLVMPointerType isn't guaranteed to have an element type, this may error?