[PATCH] D79744: clang: Add address space to indirect abi info and use it for kernels

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 11 14:35:26 PDT 2020


rjmccall added a comment.

The parameter variable is formally considered to be in a particular address space, and taking the address of it yields a pointer in that address space.  That can only work for an indirect argument if either (1) the address space of the pointer that's actually passed can be freely converted to that formal address space (because it's a subspace, or because it's a superspace but known to be in the right subspace) or (2) we're willing to copy the object into the right address space on the callee side (and able to — obviously this only works for POD types).  I do see the merit of allowing an address space to be specified for targets that consider locals to be in a different formal address space than the stack would naturally be (e.g. a generic address space); I don't remember if that applies to AMDGPU.

`byval` in LLVM is not a generic "this is a by-value argument" annotation; it specifically means that the value is actually passed on the stack despite the formally indirect convention, and therefore there's an implicit memcpy on the caller side.  That is why `byval` is inherently tied to the `alloca` address space: there's no actual pointer being passed, so it doesn't make sense to pretend it might have been promoted into a different address space.  That is also why there is no restriction to writing into the pointer: there's no reason to prevent writing to the argument slot.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79744/new/

https://reviews.llvm.org/D79744





More information about the cfe-commits mailing list