[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


================
@@ -1085,8 +1085,10 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
       blockAddr.getPointer(), ConvertType(blockInfo.getBlockExpr()->getType()));
 
   if (IsOpenCL) {
-    CGM.getOpenCLRuntime().recordBlockInfo(blockInfo.BlockExpression, InvokeFn,
-                                           result, blockInfo.StructureType);
+    CGM.getOpenCLRuntime().recordBlockInfo(
+        blockInfo.BlockExpression, InvokeFn, result, blockInfo.StructureType,
+        CurGD && CurGD.isDeclOpenCLKernel() &&
+            (CurGD.getKernelReferenceKind() == KernelReferenceKind::Kernel));
----------------
rjmccall wrote:

This is trying to protect against double-registering the block, right?  But that's only necessary if you're double-emitting the kernel body, which you really shouldn't be doing — there are a lot of other places that assume that function bodies are only emitted once, like `static` locals.  Probably the kernel should be emitted by calling the stub or vice-versa?

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


More information about the cfe-commits mailing list