Author: Sven van Haastregt Date: 2021-03-10T10:03:57Z New Revision: 6f912a2cd49150813ee467c079201b5ce3dfbbca
URL: https://github.com/llvm/llvm-project/commit/6f912a2cd49150813ee467c079201b5ce3dfbbca DIFF: https://github.com/llvm/llvm-project/commit/6f912a2cd49150813ee467c079201b5ce3dfbbca.diff LOG: [OpenCL] Set calling convention for -fdeclare-opencl-builtins IR produced using TableGen builtin function declarations (`fdeclare-opencl-builtins.cl`) did not have the target's calling convention applied to builtin calls. Fix this, and update the codegen test to check that IR produced using opencl-c.h and `-fdeclare-opencl-builtins` is identical with respect to the builtin calls. Differential Revision: https://reviews.llvm.org/D98039 Added: Modified: clang/lib/Sema/SemaLookup.cpp clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl Removed: ################################################################################ diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 4da81bb44d5b..b6bf88203745 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -755,7 +755,8 @@ static void GetOpenCLBuiltinFctOverloads( ASTContext &Context, unsigned GenTypeMaxCnt, std::vector<QualType> &FunctionList, SmallVector<QualType, 1> &RetTypes, SmallVector<SmallVector<QualType, 1>, 5> &ArgTypes) { - FunctionProtoType::ExtProtoInfo PI; + FunctionProtoType::ExtProtoInfo PI( + Context.getDefaultCallingConvention(false, false, true)); PI.Variadic = false; // Create FunctionTypes for each (gen)type. diff --git a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl index a59357e331e7..665297b469f8 100644 --- a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl +++ b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl @@ -1,8 +1,9 @@ +// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -finclude-default-header %s | FileCheck %s // RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s // Test that mix is correctly defined. // CHECK-LABEL: @test_float -// CHECK: call <4 x float> @_Z3mixDv4_fS_f +// CHECK: call spir_func <4 x float> @_Z3mixDv4_fS_f // CHECK: ret void test_float(float4 x, float a) { float4 ret = mix(x, x, a); @@ -10,7 +11,7 @@ void test_float(float4 x, float a) { // Test that Attr.Const from OpenCLBuiltins.td is lowered to a readnone attribute. // CHECK-LABEL: @test_const_attr -// CHECK: call i32 @_Z3maxii({{.*}}) [[ATTR_CONST:#[0-9]]] +// CHECK: call spir_func i32 @_Z3maxii({{.*}}) [[ATTR_CONST:#[0-9]]] // CHECK: ret int test_const_attr(int a) { return max(a, 2); @@ -18,7 +19,7 @@ int test_const_attr(int a) { // Test that Attr.Pure from OpenCLBuiltins.td is lowered to a readonly attribute. // CHECK-LABEL: @test_pure_attr -// CHECK: call <4 x float> @_Z11read_imagef{{.*}} [[ATTR_PURE:#[0-9]]] +// CHECK: call spir_func <4 x float> @_Z11read_imagef{{.*}} [[ATTR_PURE:#[0-9]]] // CHECK: ret kernel void test_pure_attr(read_only image1d_t img) { float4 resf = read_imagef(img, 42); @@ -26,7 +27,7 @@ kernel void test_pure_attr(read_only image1d_t img) { // Test that builtins with only one prototype are mangled. // CHECK-LABEL: @test_mangling -// CHECK: call i32 @_Z12get_local_idj +// CHECK: call spir_func i32 @_Z12get_local_idj kernel void test_mangling() { size_t lid = get_local_id(0); } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits