[clang] [Clang][OpenCL][AMDGPU] Allow a kernel to call another kernel (PR #115821)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 2 00:04:36 PST 2024


================
@@ -2343,6 +2343,15 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
   // Collect function IR attributes from the CC lowering.
   // We'll collect the paramete and result attributes later.
   CallingConv = FI.getEffectiveCallingConvention();
+  GlobalDecl GD = CalleeInfo.getCalleeDecl();
+  const Decl *TargetDecl = CalleeInfo.getCalleeDecl().getDecl();
+  if (TargetDecl) {
+    if (auto FD = dyn_cast<FunctionDecl>(TargetDecl)) {
+      if (FD->hasAttr<OpenCLKernelAttr>() &&
+          GD.getKernelReferenceKind() == KernelReferenceKind::Stub)
+        CallingConv = llvm::CallingConv::C;
----------------
rjmccall wrote:

This seems like the wrong place to be doing this.  If we're calling the stub, the `CGFunctionInfo` needs to contain the right CC information for the stub, and then we won't need special overrides like this.

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


More information about the cfe-commits mailing list