// RUN: %clang_cc1 -no-opaque-pointers -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=clc++ -o - %s | FileCheck %s
// RUN: %clang_cc1 -no-opaque-pointers -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=cl2.0 -o - %s | FileCheck %s
// RUN: %clang_cc1 -no-opaque-pointers -triple spir-unknown-unknown -emit-llvm -O0 -cl-std=cl3.0 -o - %s | FileCheck %s
// CHECK: %[[A:.*]] = type { float, float, float }
typedef struct {
float x,y,z;
} A;
typedef private A *PA;
typedef global A *GA;
void test {
global int *glob;
local int *loc;
private int *priv;
generic int *gen;
//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_global
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
glob = to_global;
//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_global
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
glob = to_global;
//CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_global
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
glob = to_global;
//CHECK: %[[ARG:.*]] = bitcast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_global
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
glob = to_global;
//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_local
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
loc = to_local;
//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_local
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
loc = to_local;
//CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_local
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
loc = to_local;
//CHECK: %[[ARG:.*]] = bitcast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_local
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to i32 addrspace *
loc = to_local;
//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8* @__to_private
//CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
priv = to_private;
//CHECK: %[[ARG:.*]] = addrspacecast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8* @__to_private
//CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
priv = to_private;
//CHECK: %[[ARG:.*]] = addrspacecast i32* %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8* @__to_private
//CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
priv = to_private;
//CHECK: %[[ARG:.*]] = bitcast i32 addrspace * %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8* @__to_private
//CHECK: %{{.*}} = bitcast i8* %[[RET]] to i32*
priv = to_private;
//CHECK: %[[ARG:.*]] = addrspacecast %[[A]]* %{{.*}} to i8 addrspace *
//CHECK: %[[RET:.*]] = call spir_func i8 addrspace * @__to_global
//CHECK: %{{.*}} = bitcast i8 addrspace * %[[RET]] to %[[A]] addrspace *
PA pA;
GA gA = to_global;
//CHECK-NOT: addrspacecast
//CHECK-NOT: bitcast
//CHECK: call spir_func i8 addrspace * @__to_global
//CHECK-NOT: addrspacecast
//CHECK-NOT: bitcast
generic void *gen_v;
global void *glob_v = to_global;
}