[PATCH] D137154: Adding nvvm_reflect clang builtin

Hugh Delaney via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 04:09:50 PDT 2022


hdelan marked an inline comment as not done.
hdelan added a comment.

In DPC++ for CUDA we use libclc as a wrapper around CUDA SDK's libdevice. Like libdevice we want to precompile libclc to bc for the CUDA backend without specializing for a particular arch, so that we can call different __nv funcs based on the arch. For this reason we use the `__nvvm_reflect` llvm intrinsic.

Without a clang builtin a number of workarounds are necessary to get the desired behaviour from `__nvvm_reflect`.

1. We must declare `__nvvm_reflect` in source code everywhere where it is used.
2. Some addrspace casting is necessary in openCL, since strings are in the__constant address space. We must use an IR wrapper function to ensure the correct behaviour. See https://github.com/intel/llvm/blob/sycl/libclc/ptx-nvidiacl/libspirv/reflect.ll

We agree that `__nvvm_reflect` is not a perfect solution, but it is something we must use because of libdevice. Adding the clang builtin would enable us to write libdevice-like libraries without having to resort to the methods mentioned above.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137154/new/

https://reviews.llvm.org/D137154



More information about the llvm-commits mailing list