[clang] [Clang] __has_builtin should return false for aux triple builtins (PR #121839)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 7 09:03:26 PST 2025
jhuber6 wrote:
> > I don't think it makes any sense for `__has_builtin` to return true when the target does not in-fact have the builtin. Most of the time this is used to guard target specific code, which will then be wrong if it's compiled on the device. Realistically the solution that makes sense to me is to not emit any of the aux target's builtins as available.
>
> From the user's perspective, the target DOES support the builtin though, since from their perspective, their target is 'SYCL host + device'. So this is actually not as clear as "it should never", because target/aux-target are machinations of the implementation, and don't properly respect the user's definition of 'target'.
I don't see how this is desirable behavior, since it just leads to stuff like this https://godbolt.org/z/na4rGn9od. This behavior makes `__has_builtin` effectively unusable if you ever use it inside a function shared with the host + device.
https://github.com/llvm/llvm-project/pull/121839
More information about the cfe-commits
mailing list