[llvm] [NVPTX] Add errors for incorrect CUDA addrpaces (PR #138706)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 03:12:15 PDT 2025
================
@@ -1399,19 +1399,27 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
if (PTy) {
O << "\t.param .u" << PTySizeInBits << " .ptr";
+ bool IsCUDA = static_cast<NVPTXTargetMachine &>(TM).getDrvInterface() ==
+ NVPTX::CUDA;
switch (PTy->getAddressSpace()) {
default:
break;
case ADDRESS_SPACE_GLOBAL:
O << " .global";
break;
case ADDRESS_SPACE_SHARED:
+ if (IsCUDA)
+ report_fatal_error(".shared ptr kernel args unsupported in CUDA.");
O << " .shared";
break;
case ADDRESS_SPACE_CONST:
+ if (IsCUDA)
+ report_fatal_error(".const ptr kernel args unsupported in CUDA.");
----------------
gonzalobg wrote:
IIRC this change was motivated as a quality of life improvement for developers of non-cuda frontends (openmp/-acc offloading, c++ parallel algorithms, ...) that support a variety of backends (cuda ptx, opencl, ...). The set of state spaces each such backend supports for pointers passed as kernel arguments differs, leading to bugs in those frontends. IIRC, not all ptxas versions diagnose these sort of issues correctly, making the life of those frontend developers unnecessarily miserable. The LLVM NVPTX backend does support a wide range of ptxas versions, so detecting these issues there and providing a clear and concise error message about what went wrong seemed valuable.
https://github.com/llvm/llvm-project/pull/138706
More information about the llvm-commits
mailing list