Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -5523,6 +5523,12 @@ Fn->addFnAttr("branch-target-enforcement", BPI.BranchTargetEnforcement ? "true" : "false"); } + + unsigned getOpenCLKernelCallingConv() const override { + // OpenCL kernels use calling convention from the regular functions + // as there is no special support for threads. + return llvm::CallingConv::C; + } }; class WindowsAArch64TargetCodeGenInfo : public AArch64TargetCodeGenInfo { @@ -6328,6 +6334,12 @@ B.addStackAlignmentAttr(8); Fn->addAttributes(llvm::AttributeList::FunctionIndex, B); } + + unsigned getOpenCLKernelCallingConv() const override { + // OpenCL kernels use calling convention from the regular functions + // as there is no special support for threads. + return llvm::CallingConv::C; + } }; class WindowsARMTargetCodeGenInfo : public ARMTargetCodeGenInfo { Index: clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl =================================================================== --- clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl +++ clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl @@ -1,9 +1,16 @@ // RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s // RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple amdgcn-unknown-unknown -o - | FileCheck -check-prefixes=AMDGCN %s -// Test that the kernels always use the SPIR calling convention -// to have unambiguous mapping of arguments to feasibly implement +// RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple arm -o - | FileCheck -check-prefixes=ARM %s +// RUN: %clang_cc1 %s -cl-std=CL1.2 -emit-llvm -triple aarch64 -o - | FileCheck -check-prefixes=AARCH64 %s + +// Test that the kernels use the SPIR calling convention for targets that +// support it. +// This facilitates unambiguous mapping of arguments to feasibly implement // clSetKernelArg(). +// ARM-NOT: spir_kernel +// AARCH64-NOT: spir_kernel + typedef struct int_single { int a; } int_single; @@ -21,7 +28,10 @@ long elementE; float elementF; short elementG; +// FIXME: double type should be enabled correctly for Arm CPU. +#if !defined(__ARM_ARCH) double elementH; +#endif } test_struct; kernel void test_single(int_single input, global int* output) { @@ -53,7 +63,9 @@ output[4] = (int)input.elementE; output[5] = (int)input.elementF; output[6] = (int)input.elementG; +#if !defined(__ARM_ARCH) output[7] = (int)input.elementH; +#endif }; void test_function(int_pair input, global int* output) {