[clang] [llvm] [NVPTX] Add errors for incorrect CUDA addrpaces (PR #138706)

Artem Belevich via cfe-commits cfe-commits at lists.llvm.org
Mon May 19 15:13:43 PDT 2025


================
@@ -2927,6 +2928,20 @@ void Verifier::visitFunction(const Function &F) {
           "Calling convention does not support varargs or "
           "perfect forwarding!",
           &F);
+    if (F.getCallingConv() == CallingConv::PTX_Kernel &&
+        TT.getOS() == Triple::CUDA) {
+      for (const Argument &Arg : F.args()) {
+        if (Arg.getType()->isPointerTy()) {
+          auto AS = Arg.getType()->getPointerAddressSpace();
+          Check(AS != NVPTXAS::AddressSpace::ADDRESS_SPACE_SHARED,
+                ".shared ptr kernel args unsupported in CUDA.", &Arg, &F);
----------------
Artem-B wrote:

I think the check should be rephrased to only allow generic and grlobal AS, and error out on anything else, so we don't have to update it when a new AS is added, or if/when someone uses a nonsensical AS.

https://github.com/llvm/llvm-project/pull/138706


More information about the cfe-commits mailing list