summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenOpenCL
diff options
context:
space:
mode:
authorSven van Haastregt <sven.vanhaastregt@arm.com>2019-11-05 10:07:43 +0000
committerSven van Haastregt <sven.vanhaastregt@arm.com>2019-11-05 10:26:47 +0000
commit9a8d477a0e00c15d6d33a52486fa931483b7f2ea (patch)
tree0c0fd20a1bb13aabce83e8145aff625d1a2e98b3 /clang/test/CodeGenOpenCL
parent4ecff91ed1df05edbdb55cb2ccdf58466f1333b0 (diff)
downloadbcm5719-llvm-9a8d477a0e00c15d6d33a52486fa931483b7f2ea.tar.gz
bcm5719-llvm-9a8d477a0e00c15d6d33a52486fa931483b7f2ea.zip
[OpenCL] Add builtin function attribute handling
Add handling for the "pure", "const" and "convergent" function attributes for OpenCL builtin functions. Patch by Pierre Gondois and Sven van Haastregt. Differential Revision: https://reviews.llvm.org/D64319
Diffstat (limited to 'clang/test/CodeGenOpenCL')
-rw-r--r--clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl22
1 files changed, 22 insertions, 0 deletions
diff --git a/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
new file mode 100644
index 00000000000..7e3186b1861
--- /dev/null
+++ b/clang/test/CodeGenOpenCL/fdeclare-opencl-builtins.cl
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
+
+// 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: ret
+int test_const_attr(int a) {
+ return max(a, 2);
+}
+
+// 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: ret
+kernel void test_pure_attr(read_only image1d_t img) {
+ float4 resf = read_imagef(img, 42);
+}
+
+// CHECK: attributes [[ATTR_CONST]] =
+// CHECK-SAME: readnone
+// CHECK: attributes [[ATTR_PURE]] =
+// CHECK-SAME: readonly
OpenPOWER on IntegriCloud