[llvm] 3ac5c07 - [NVPTX] Do not permit calls to ptx_kernel CC (#190434)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 06:11:57 PDT 2026


Author: Joseph Huber
Date: 2026-04-09T08:11:51-05:00
New Revision: 3ac5c07e202fbb6525a1c689547b2de3c69a9b77

URL: https://github.com/llvm/llvm-project/commit/3ac5c07e202fbb6525a1c689547b2de3c69a9b77
DIFF: https://github.com/llvm/llvm-project/commit/3ac5c07e202fbb6525a1c689547b2de3c69a9b77.diff

LOG: [NVPTX] Do not permit calls to ptx_kernel CC (#190434)

Summary:
Removes support for calling the ptx_kernel CC. Regenerate bitcode that
used it, no auto upgrade because this never worked, it just wasn't
diagnosed.

Added: 
    

Modified: 
    llvm/include/llvm/IR/CallingConv.h
    llvm/test/Bitcode/calling-conventions.3.2.ll
    llvm/test/Bitcode/calling-conventions.3.2.ll.bc
    llvm/test/Verifier/call-to-non-callable-functions.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/CallingConv.h b/llvm/include/llvm/IR/CallingConv.h
index bbf9f8486f31c..249c512dda532 100644
--- a/llvm/include/llvm/IR/CallingConv.h
+++ b/llvm/include/llvm/IR/CallingConv.h
@@ -323,6 +323,7 @@ constexpr bool isCallableCC(CallingConv::ID CC) {
   case CallingConv::AMDGPU_PS:
   case CallingConv::AMDGPU_VS:
   case CallingConv::SPIR_KERNEL:
+  case CallingConv::PTX_Kernel:
     return false;
   default:
     return true;

diff  --git a/llvm/test/Bitcode/calling-conventions.3.2.ll b/llvm/test/Bitcode/calling-conventions.3.2.ll
index 678886777ad4c..a6fe433d6c76c 100644
--- a/llvm/test/Bitcode/calling-conventions.3.2.ll
+++ b/llvm/test/Bitcode/calling-conventions.3.2.ll
@@ -140,12 +140,6 @@ define void @call_msp430_intrcc() {
   ret void
 }
 
-define void @call_ptx_kernel() {
-; CHECK: call ptx_kernel void @ptx_kernel
-  call ptx_kernel void @ptx_kernel()
-  ret void
-}
-
 define void @call_ptx_device() {
 ; CHECK: call ptx_device void @ptx_device
   call ptx_device void @ptx_device()

diff  --git a/llvm/test/Bitcode/calling-conventions.3.2.ll.bc b/llvm/test/Bitcode/calling-conventions.3.2.ll.bc
index 19cdf69be1c26..9413d5bd2285b 100644
Binary files a/llvm/test/Bitcode/calling-conventions.3.2.ll.bc and b/llvm/test/Bitcode/calling-conventions.3.2.ll.bc 
diff er

diff  --git a/llvm/test/Verifier/call-to-non-callable-functions.ll b/llvm/test/Verifier/call-to-non-callable-functions.ll
index f33682c0dbe23..adbb4e90d11ad 100644
--- a/llvm/test/Verifier/call-to-non-callable-functions.ll
+++ b/llvm/test/Verifier/call-to-non-callable-functions.ll
@@ -527,3 +527,51 @@ cont:
 unwind:
   ret void
 }
+
+declare ptx_kernel void @callee_ptx_kernel()
+
+; CHECK: calling convention does not permit calls
+; CHECK-NEXT: call ptx_kernel void @callee_ptx_kernel()
+define ptx_kernel void @call_caller_ptx_kernel() {
+entry:
+  call ptx_kernel void @callee_ptx_kernel()
+  ret void
+}
+
+; CHECK: calling convention does not permit calls
+; CHECK-NEXT: call ptx_kernel void %func()
+define ptx_kernel void @indirect_call_caller_ptx_kernel(ptr %func) {
+entry:
+  call ptx_kernel void %func()
+  ret void
+}
+
+; CHECK: calling convention does not permit calls
+; CHECK-NEXT: invoke ptx_kernel void @callee_ptx_kernel()
+; CHECK-NEXT: to label %cont unwind label %unwind
+define ptx_kernel void @invoke_caller_ptx_kernel() {
+entry:
+  invoke ptx_kernel void @callee_ptx_kernel() to label %cont unwind label %unwind
+  ret void
+
+cont:
+  ret void
+
+unwind:
+  ret void
+}
+
+; CHECK: calling convention does not permit calls
+; CHECK: invoke ptx_kernel void %func()
+; CHECK-NEXT: to label %cont unwind label %unwind
+define ptx_kernel void @indirect_invoke_caller_ptx_kernel(ptr %func) {
+entry:
+  invoke ptx_kernel void %func() to label %cont unwind label %unwind
+  ret void
+
+cont:
+  ret void
+
+unwind:
+  ret void
+}


        


More information about the llvm-commits mailing list