1// RUN: %clang_cc1 %s -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s
2
3// CHECK: %struct.X = type { i32 }
4
5// CHECK: @ci ={{.*}} addrspace(2) constant i32 0
6// CHECK: @gi ={{.*}} addrspace(1) global i32 0
7__constant int ci = 0;
8__global int gi = 0;
9
10struct X {
11  int x;
12
13  // Local variables are handled in local_addrspace_init.clcpp
14  // FIXME: __private and __generic constructors clash for __private variable
15  // X() /*__generic*/ = default;
16  X() __private : x(0) {}
17  X() __global : x(0) {}
18  constexpr X() __constant : x(0) {}
19  constexpr X(int x) __constant : x(x) {}
20};
21
22// CHECK: @cx1 ={{.*}} addrspace(2) constant %struct.X zeroinitializer
23// CHECK: @cx2 ={{.*}} addrspace(2) constant %struct.X { i32 1 }
24// CHECK: @gx ={{.*}} addrspace(1) global %struct.X zeroinitializer
25__constant X cx1;
26__constant X cx2(1);
27__global X gx;
28
29// CHECK: @_ZZ1kE3cx1 = internal addrspace(2) constant %struct.X zeroinitializer
30// CHECK: @_ZZ1kE3cx2 = internal addrspace(2) constant %struct.X { i32 1 }
31
32kernel void k() {
33  // Check that the constructor for px is executed
34  // CHECK: %px = alloca %struct.X
35  // CHECK-NEXT: call spir_func void @_ZN1XC1Ev(%struct.X* {{.*}}%px)
36  __private X px;
37
38  __constant X cx1;
39  __constant X cx2(1);
40  // CHECK-NEXT: ret void
41}
42