Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Why do you need this? Typed pointers have very limited use as a representational convenience. They should not be recognized or handled like normal pointers.
I'm trying to construct a vector of pointers in the patch in the related project that does a translation of LLVM IR to SPIR-V (if you are interested here it is: https://github.com/KhronosGroup/SPIRV-LLVM-Translator/pull/1669 ). As for now SPIR-V doesn't have opaque pointers and hence this vector needs to be created with typed pointers. Like this I'm getting an assert "Element type of a VectorType must be an integer, floating point, or pointer type.", which is a bit weird from my perspective. Probably this fix is not the best (or may be just wrong), but I don't see any reasons to not allow creating of a typed pointer vector. So I'm keen to hear your opinion.
I'm similarly skeptical that this is the best way to go about the problem. Making typed pointers qualify under isPointerTy() potentially breaks a lot of code that assumes isPointerTy() means that it is indeed a PointerType, although this is ameliorated to some degree by the hard prohibition llvm::Value has on construction types with TypedPointerType.
If the problem is that vector types cannot be constructed with typed pointer types as element types, then the best fix is probably to adjust VectorType::isValidElementType to allow typed pointer types as well (and adjust the checkType assertion for Value to check !isa<TypedPointerType>(Ty->getScalarType()) to ensure that vectors-of-typed-pointer-types don't leak into IR).
This looks okay, but it would be good for @jcranmer-intel to confirm that this is strictly required.
Thanks! Probably the name of the commit should be not "Make typed pointers to be yet again recognized as pointers" but "Allow typed pointers to be base of VectorType". I don't have merge rights in llvm.org, so it would be nice if someone helps with merging.