This is an archive of the discontinued LLVM Phabricator instance.

[Builtins][FIX] Allow targets to opt-out of `long double` builtins
AbandonedPublic

Authored by jdoerfert on Jan 28 2021, 10:43 PM.

Details

Summary

If a target doesn't support long double, e.g., a GPU, it should not
expose the builtins that deal with them in the first place. This patch
also adjusts __has_builtin to return false in those cases.

This is a first step to fix PR48923, second is to adjust libcxx and
add the __has_builtin guards.

Diff Detail

Event Timeline

jdoerfert created this revision.Jan 28 2021, 10:43 PM
jdoerfert requested review of this revision.Jan 28 2021, 10:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 28 2021, 10:43 PM

Can you show any tests where this builtin would be a part of the aux-triple, and not in active code? So an nvptx triple, x86_64 aux-triple, and in non-device code? (such as in a CUDA app)?

I tried this patch with our CI and it breaks HIP and OpenMP. I suspect it may also break CUDA. It seems in device compilation, when a host function calls a builtin with long double argument, the builtin is not found. My guess is that the target for checking builtin needs to be caller dependent. E.g. in device compilation, when checking builtin called by a host function, aux-target and aux-cpu should be used. Then this raises another question: what to use for host device function? It seems for this to work, the dianostic about missing builtin needs to be also deferred diagnostics.

For target-specific builtins I ended up implementing this: https://github.com/llvm/llvm-project/commit/81a73fde5cea304d31294fd26c2f051f1685e97c at one point to make sure that 'host' builtins get looked up in the aux-target if necessary.

jdoerfert abandoned this revision.Jan 30 2021, 12:42 PM

I guess this doesn't work then.