@@ -103,18 +103,21 @@ TargetCodeGenInfo::getDependentLibraryOption(llvm::StringRef Lib,
103103 Opt += Lib;
104104}
105105
106- unsigned TargetCodeGenInfo::getOpenCLKernelCallingConv () const {
107- // OpenCL kernels are called via an explicit runtime API with arguments
108- // set with clSetKernelArg(), not as normal sub-functions.
109- // Return SPIR_KERNEL by default as the kernel calling convention to
110- // ensure the fingerprint is fixed such way that each OpenCL argument
111- // gets one matching argument in the produced kernel function argument
112- // list to enable feasible implementation of clSetKernelArg() with
113- // aggregates etc. In case we would use the default C calling conv here,
114- // clSetKernelArg() might break depending on the target-specific
115- // conventions; different targets might split structs passed as values
116- // to multiple function arguments etc.
117- return llvm::CallingConv::SPIR_KERNEL;
106+ unsigned TargetCodeGenInfo::getDeviceKernelCallingConv () const {
107+ if (getABIInfo ().getContext ().getLangOpts ().OpenCL ) {
108+ // Device kernels are called via an explicit runtime API with arguments,
109+ // such as set with clSetKernelArg() for OpenCL, not as normal
110+ // sub-functions. Return SPIR_KERNEL by default as the kernel calling
111+ // convention to ensure the fingerprint is fixed such way that each kernel
112+ // argument gets one matching argument in the produced kernel function
113+ // argument list to enable feasible implementation of clSetKernelArg() with
114+ // aggregates etc. In case we would use the default C calling conv here,
115+ // clSetKernelArg() might break depending on the target-specific
116+ // conventions; different targets might split structs passed as values
117+ // to multiple function arguments etc.
118+ return llvm::CallingConv::SPIR_KERNEL;
119+ }
120+ llvm_unreachable (" Unknown kernel calling convention" );
118121}
119122
120123void TargetCodeGenInfo::setOCLKernelStubCallingConvention (
0 commit comments