This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Kernel calls lowering
AbandonedPublic

Authored by rampitec on Aug 19 2019, 10:47 AM.

Details

Summary

In OpenCL, a kernel may call another kernel as if it was a non-kernel
function. However, kernels and functions have different ABI. To fix this,
we copy the body of kernel A into a new non-kernel function fA, if we
encounter a call to A. All calls to A are then transferred to fA.

Diff Detail

Event Timeline

rampitec created this revision.Aug 19 2019, 10:47 AM
arsenm requested changes to this revision.Aug 19 2019, 10:49 AM

This pass should be removed. Clang needs to emit a separate function body up-front. I want the IR verifier to reject all calls to kernels. Since a module may need to export a callable function with the name of the kernel, this has a name mangling impact that the frontend needs to take care of

This revision now requires changes to proceed.Aug 19 2019, 10:49 AM

This pass should be removed. Clang needs to emit a separate function body up-front. I want the IR verifier to reject all calls to kernels. Since a module may need to export a callable function with the name of the kernel, this has a name mangling impact that the frontend needs to take care of

I agree in general. However, we do not support late linking so far but do support OpenCL. Is there any reason to keep this pass even as a temporary solution in the private branch?

This pass should be removed. Clang needs to emit a separate function body up-front. I want the IR verifier to reject all calls to kernels. Since a module may need to export a callable function with the name of the kernel, this has a name mangling impact that the frontend needs to take care of

I agree in general. However, we do not support late linking so far but do support OpenCL. Is there any reason to keep this pass even as a temporary solution in the private branch?

I can't imagine the clang patch is a lot of work, but nobody's ever done it. Ignoring the name mangling problem, it shouldn't be difficult to just emit the two separate functions directly

This pass should be removed. Clang needs to emit a separate function body up-front. I want the IR verifier to reject all calls to kernels. Since a module may need to export a callable function with the name of the kernel, this has a name mangling impact that the frontend needs to take care of

I agree in general. However, we do not support late linking so far but do support OpenCL. Is there any reason to keep this pass even as a temporary solution in the private branch?

I can't imagine the clang patch is a lot of work, but nobody's ever done it. Ignoring the name mangling problem, it shouldn't be difficult to just emit the two separate functions directly

I do not think there is a mangling problem. Prefix "__" is reserved for internal use. But then again, even if you do it in clang we will internalize the function. You will end up in the same situation.

rampitec abandoned this revision.Aug 21 2020, 1:28 AM