[libc-commits] [clang] [libc] [clang][NVPTX] Preserve sin calls for GPU libc (PR #243003)
via libc-commits
libc-commits at lists.llvm.org
Fri Nov 20 23:08:39 PST 2026
sriramshastry wrote:
Thanks @arsenm, @jhuber6. Agreed: preserving the `sin` libcall in the frontend doesn't solve the problem, which is that intrinsics (written directly or recreated by optimization) have no symbol for archive resolution to find before the backend lowers them.
Direction I would like to try, before touching the PR:
Make the libcall dependencies visible before device LTO resolves archives, either by lowering the intrinsics to calls before linking (as jhuber6 described) or by teaching LTO's runtime-libcall symbol lookup about the libcalls the NVPTX backend can emit. The second needs a backend declaration; I'd like to know which you prefer.
Diagnose any dependency that is still unresolved after the LTO input set is fixed, rather than failing late in the backend.
Evidence so far: with a local patch, f64 `sin` and `atan` link against a real LLVM-libc NVPTX `libm.a` and emit calls at `sm_120`. I have not run on a GPU, and f32/ThinLTO are untested.
https://github.com/llvm/llvm-project/pull/243003
More information about the libc-commits
mailing list