[clang] [Clang] Add `-fdefault-generic-addrspace` flag for targeting GPUs (PR #115777)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 11 16:30:34 PST 2024
Artem-B wrote:
I think I generally agree with @AlexVlx argument. While the patch may solve you immediate issue, I think it's not going to give you a usable compilation model for AS-qualified pointers.
If you are defining your own C++ extension along the lines of CUDA/HIP/OpenCL, you would have some wiggle room on how you want things to behave, but if you want it to be a regular C++ compilation, you've got to play by C++ rules. The diagnostics in your example looks quite sensible to me -- you're asking compiler to do <magic> with things of different types, but you do not provide implementation for it. and because C++ has no idea about what can and can't be done with non-default AS, it's all on you to do it.
I don't think you can have this cake (explicit AS-qualified pointers) and eat it (make them all usable out of the box in a consistent manner, magically compatible with everything C++). Sticking `__generic` on plain pointer types will likely lead to issues.
For example, it looks like the pointer promotion will be ABI-breaking. How will you mangle function names with pointer arguments? Normally AS is encoded in the mangled name. And both the caller and callee must be in sync in order to call the right function -> therefore everything must be compiled with the same setting of this flag, including libc, etc.
https://github.com/llvm/llvm-project/pull/115777
More information about the cfe-commits
mailing list