[llvm] [NVPTX] Do not permit calls to ptx_kernel CC (PR #190434)

Joseph Huber via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 6 05:53:53 PDT 2026


https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/190434

>From 8b03ada97caff703b3e4234055c10c62e9336209 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 3 Apr 2026 19:00:16 -0500
Subject: [PATCH 1/2] [NVPTX] Do not permit calls to ptx_kernel CC

Summary:
Does what it says on the tin. I had to delete the uselists portion of
the test because the `.bc` file cannot be regenerated. It was created
with a very old version of LLVM. Either we remove the test entirely,
somehow get llvm-as3.2, or remove this line.
---
 llvm/include/llvm/IR/CallingConv.h            |  1 +
 llvm/test/Bitcode/calling-conventions.3.2.ll  |  1 -
 .../call-to-non-callable-functions.ll         | 48 +++++++++++++++++++
 3 files changed, 49 insertions(+), 1 deletion(-)

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..66d76dd1a93ab 100644
--- a/llvm/test/Bitcode/calling-conventions.3.2.ll
+++ b/llvm/test/Bitcode/calling-conventions.3.2.ll
@@ -1,5 +1,4 @@
 ; RUN:  llvm-dis < %s.bc| FileCheck %s
-; RUN:  verify-uselistorder < %s.bc
 
 ; calling-conventions.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
 ; The test checks that LLVM does not silently misread calling conventions of
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
+}

>From a21037679d4aab874c702a97507e7fe5c0f5f915 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 6 Apr 2026 07:53:43 -0500
Subject: [PATCH 2/2] Just regenerate

---
 llvm/test/Bitcode/calling-conventions.3.2.ll  |   7 +------
 .../Bitcode/calling-conventions.3.2.ll.bc     | Bin 2888 -> 3032 bytes
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/llvm/test/Bitcode/calling-conventions.3.2.ll b/llvm/test/Bitcode/calling-conventions.3.2.ll
index 66d76dd1a93ab..a6fe433d6c76c 100644
--- a/llvm/test/Bitcode/calling-conventions.3.2.ll
+++ b/llvm/test/Bitcode/calling-conventions.3.2.ll
@@ -1,4 +1,5 @@
 ; RUN:  llvm-dis < %s.bc| FileCheck %s
+; RUN:  verify-uselistorder < %s.bc
 
 ; calling-conventions.3.2.ll.bc was generated by passing this file to llvm-as-3.2.
 ; The test checks that LLVM does not silently misread calling conventions of
@@ -139,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 19cdf69be1c26552e8208b56efc3feba41caf047..9413d5bd2285bbfdd105174032c2cf95d74bc8bb 100644
GIT binary patch
delta 1516
zcmX>hc0+uEh-~feE&kFcR9qO1SQ!*~7#NC}7#O&j6d8aNgYrZ}h59b#78UW96ACFB
z1p)@sL{d@&CMKM8YU2^)?6XK|@pv>rP{|{xfk#qt8dJ&%4nY-52e&qX(~L$&EgVK6
z0U-*DcR08eHS$Orwee5WHcF9@^yD*2ITBGcK~dRlf~tV5Rmq8tz6pvhZ9ObTCJYRn
z3JeUKK)aRFSOhjXHJzNeLZSZtfu~g)Z+`pM9XIcC{2`OtKWfwC9~;b`TQ)!X@%Gzs
zWtT7Kf4^f|d@?5In*g^23(y1 at XkcV$i)dC<V1x-UFz_%K9P#2&1la)v2 at DO2*PJ=L
zV0<9W%)qm8nQKBTSg0N%!NwqwRN1+K3(YJmX7>z;I)t*T2bF!$lqt2kF`z3u+N9j#
z1knX1LAKT%6!cL<h=Dv%AMthp$07lQ-~k2(=QY(4ErA>eF_0&wdDt*%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