================
@@ -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.");
----------------
LewisCrawford wrote:

>Is it the argument declaration as a the pointer in non-generic/global AS that 
>causes the runtime failure?
Or is that dereferencing of that pointer?

The example in 
https://github.com/llvm/llvm-project/pull/114874#issuecomment-2658056661 is an 
empty program that does not dereference anything. Merely launching a kernel 
with a pointer declared in those address-spaces is enough to trigger a run-time 
error, even if the pointer declarations are unused.

I agree that Asm printer is a convenient but suboptimal place for this. I'll 
look in to moving this to an IR validation step somewhere earlier in the 
pipeline.

https://github.com/llvm/llvm-project/pull/138706
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to