-
Notifications
You must be signed in to change notification settings - Fork 203
Description
In both NVVM IR & LLVM in general, using bitcasts to change address spaces is UB:
bitcast on pointers is supported, though LLVM IR forbids bitcast from being used to change the address space of a pointer.
The addrspacecast IR instruction should be used to perform pointer casts across address spaces (generic to non-generic or non-generic to generic). Casting a non-generic pointer to a different non-generic pointer is not supported. Casting from a generic to a non-generic pointer is undefined if the generic pointer does not point to an object in the target non-generic address space.
However, we do use bitcasts quite liberally in cg_nvvm
, frequently to change the address space of a pointer.
llvm::LLVMBuildPointerCast(bx.llbuilder, alloca, self.cx().type_ptr(), UNNAMED) |
We should use address space casts here instead. The main problem will probably be catching all the places where we do this sort of thing.