1*532dc62bSNikita Popov// RUN: %clang_cc1 -no-opaque-pointers %s -cl-std=clc++1.0 -DGENERIC -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s 2*532dc62bSNikita Popov// RUN: %clang_cc1 -no-opaque-pointers %s -cl-std=clc++2021 -DGENERIC -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s 3*532dc62bSNikita Popov// RUN: %clang_cc1 -no-opaque-pointers %s -cl-std=clc++2021 -cl-ext=-all,+__opencl_c_program_scope_global_variables -emit-llvm -o - -O0 -triple spir-unknown-unknown | FileCheck %s 4642d2f00SOle Strohm 5642d2f00SOle Strohm// CHECK: %struct.X = type { i32 } 6642d2f00SOle Strohm 7ac06f6d0SFangrui Song// CHECK: @ci ={{.*}} addrspace(2) constant i32 0 8ac06f6d0SFangrui Song// CHECK: @gi ={{.*}} addrspace(1) global i32 0 9642d2f00SOle Strohm__constant int ci = 0; 10642d2f00SOle Strohm__global int gi = 0; 11642d2f00SOle Strohm 12642d2f00SOle Strohmstruct X { 13642d2f00SOle Strohm int x; 14642d2f00SOle Strohm 15642d2f00SOle Strohm // Local variables are handled in local_addrspace_init.clcpp 16388e8110SJustas Janickas X() /*__generic or __private*/ : x(0) {} 17388e8110SJustas Janickas#if defined(GENERIC) 18642d2f00SOle Strohm X() __private : x(0) {} 19388e8110SJustas Janickas#endif 20642d2f00SOle Strohm X() __global : x(0) {} 21642d2f00SOle Strohm constexpr X() __constant : x(0) {} 22642d2f00SOle Strohm constexpr X(int x) __constant : x(x) {} 23642d2f00SOle Strohm}; 24642d2f00SOle Strohm 25ac06f6d0SFangrui Song// CHECK: @cx1 ={{.*}} addrspace(2) constant %struct.X zeroinitializer 26ac06f6d0SFangrui Song// CHECK: @cx2 ={{.*}} addrspace(2) constant %struct.X { i32 1 } 27ac06f6d0SFangrui Song// CHECK: @gx ={{.*}} addrspace(1) global %struct.X zeroinitializer 28642d2f00SOle Strohm__constant X cx1; 29642d2f00SOle Strohm__constant X cx2(1); 30642d2f00SOle Strohm__global X gx; 31642d2f00SOle Strohm 32642d2f00SOle Strohm// CHECK: @_ZZ1kE3cx1 = internal addrspace(2) constant %struct.X zeroinitializer 33642d2f00SOle Strohm// CHECK: @_ZZ1kE3cx2 = internal addrspace(2) constant %struct.X { i32 1 } 34642d2f00SOle Strohm 35642d2f00SOle Strohmkernel void k() { 36b102e688SOle Strohm // Check that the constructor for px calls the __private constructor. 37642d2f00SOle Strohm // CHECK: %px = alloca %struct.X 38642d2f00SOle Strohm // CHECK-NEXT: call spir_func void @_ZN1XC1Ev(%struct.X* {{.*}}%px) 39642d2f00SOle Strohm __private X px; 40642d2f00SOle Strohm 41642d2f00SOle Strohm __constant X cx1; 42642d2f00SOle Strohm __constant X cx2(1); 43642d2f00SOle Strohm // CHECK-NEXT: ret void 44642d2f00SOle Strohm} 45