[clang] [clang-tools-extra] [Clang] Use TargetInfo when deciding is an address space is compatible (PR #115777)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 13 06:42:42 PST 2024


AaronBallman wrote:

> Interesting, though reading through that I didn't see any mentions of implicit casts. It's simply stating that they can do casting if the target lists them as a subset.

That matches my understanding -- implicit or explicit casts require a subset relationship, as best I understand.

> Also it's worth noting that in the documentation it has stuff like __X char x, y, z which is a warning in clang due to how type level attributes work https://godbolt.org/z/Pfv36nEdq.

This is because the TR was written before we had attributes. AIUI, the TR is written with the idea that address spaces are specified via qualifiers (so more like `__global__`, for example). But the important bit is that the address space is a property of the type (and for `[[]]` attributes, there's specific syntactic requirements for where the attribute has to be written to apply to the type).

> Maybe someone who reads better standardese than me can help with this. My ultimate goal is to make this legal when targeting NVPTX or AMDGPU, which is easily done by stating that DefaultAS is a superset of these other AS's. Let me know if making this target dependent is a good idea.
> ```
> void *foo(void [[clang::addrspace(3) *p) { return p; }
> ```

Making sure I understand your example, you want a pointer in the generic address space to an object in address space three? As opposed to `void * [[clang::address_space(3)]] p` which would be a pointer in address space three to an object in the generic address space?

https://github.com/llvm/llvm-project/pull/115777


More information about the cfe-commits mailing list