1// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -ffake-address-space-map -cl-std=CL2.0 -emit-llvm -o - | FileCheck %s 2 3// test that we generate address space casts everywhere we need conversions of 4// pointers to different address spaces 5 6void test(global int *arg_glob, generic int *arg_gen) { 7 int var_priv; 8 arg_gen = arg_glob; // implicit cast global -> generic 9 // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(4)* 10 arg_gen = &var_priv; // implicit cast with obtaining adr, private -> generic 11 // CHECK: %{{[0-9]+}} = addrspacecast i32* %var_priv to i32 addrspace(4)* 12 arg_glob = (global int *)arg_gen; // explicit cast 13 // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(4)* %{{[0-9]+}} to i32 addrspace(1)* 14 global int *var_glob = 15 (global int *)arg_glob; // explicit cast in the same address space 16 // CHECK-NOT: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(1)* 17 var_priv = arg_gen - arg_glob; // arithmetic operation 18 // CHECK: %{{.*}} = ptrtoint i32 addrspace(4)* %{{.*}} to i64 19 // CHECK: %{{.*}} = ptrtoint i32 addrspace(1)* %{{.*}} to i64 20 var_priv = arg_gen > arg_glob; // comparison 21 // CHECK: %{{[0-9]+}} = addrspacecast i32 addrspace(1)* %{{[0-9]+}} to i32 addrspace(4)* 22} 23