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.
Details
Diff Detail
Event Timeline
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.