[clang] [Clang] __has_builtin should return false for aux triple builtins (PR #121839)
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 8 08:42:00 PST 2025
yxsamliu wrote:
I am afraid this will break all existing CUDA/HIP programs since they expect to be able to parse the builtins for both host and device targets.
In the spirit of single source, the compiler sees the entire code for all targets, including host target and all device targets. It is supposed to have AST for all host and device targets. Ideally, it should generate a heterogeneous IR that is for all host and device targets, and eventually generate a heterogeneous executable that includes everything. That would make some optimizations across host and device IR possible. It is just due to current limitation of LLVM/Clang, we generate and process IR separately for each host and device target.
I think at least during parsing/sema/AST clang could and should see code and AST for both host and device, since that helps avoid inconsistency between host and device. Therefore it is necessary to see builtins for both host and device. Clang only needs to make sure they are only emitted for the supported target.
https://github.com/llvm/llvm-project/pull/121839
More information about the cfe-commits
mailing list