1// RUN: %clang_cc1 -emit-llvm -o - -O0 -triple spir-unknown-unknown -fdeclare-opencl-builtins -finclude-default-header %s | FileCheck %s
2
3// Test that Attr.Const from OpenCLBuiltins.td is lowered to a readnone attribute.
4// CHECK-LABEL: @test_const_attr
5// CHECK: call i32 @_Z3maxii({{.*}}) [[ATTR_CONST:#[0-9]]]
6// CHECK: ret
7int test_const_attr(int a) {
8  return max(a, 2);
9}
10
11// Test that Attr.Pure from OpenCLBuiltins.td is lowered to a readonly attribute.
12// CHECK-LABEL: @test_pure_attr
13// CHECK: call <4 x float> @_Z11read_imagef{{.*}} [[ATTR_PURE:#[0-9]]]
14// CHECK: ret
15kernel void test_pure_attr(read_only image1d_t img) {
16  float4 resf = read_imagef(img, 42);
17}
18
19// Test that builtins with only one prototype are mangled.
20// CHECK-LABEL: @test_mangling
21// CHECK: call i32 @_Z12get_local_idj
22kernel void test_mangling() {
23  size_t lid = get_local_id(0);
24}
25
26// CHECK: attributes [[ATTR_CONST]] =
27// CHECK-SAME: readnone
28// CHECK: attributes [[ATTR_PURE]] =
29// CHECK-SAME: readonly
30