brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · a0ed03b Raw
63 lines · plain
1// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s2// RUN: %clang_cc1 %s -triple spir-unknown-unknown -emit-llvm -O0 -o - | FileCheck %s --check-prefix=CHECK-DEFINITIONS3 4// This test ensures the proper address spaces and address space cast are used5// for constructors, member functions and destructors.6// See also atexit.cl and global_init.cl for other specific tests.7 8// CHECK: %struct.MyType = type { i32, [5 x i32] }9struct MyType {10  MyType(int i) : i(i) {}11  MyType(int i) __constant : i(i) {}12  ~MyType() {}13  ~MyType() __constant {}14  int bar() { return i + 2; }15  int bar() __constant { return i + 1; }16  int i;17  int a[5] = {42, 43, 44, 45, 46};18};19 20// CHECK: @const1 ={{.*}} addrspace(2) global %struct.MyType zeroinitializer21__constant MyType const1 = 1;22// CHECK: @const2 ={{.*}} addrspace(2) global %struct.MyType zeroinitializer23__constant MyType const2(2);24// CHECK: @glob ={{.*}} addrspace(1) global %struct.MyType zeroinitializer25MyType glob(1);26 27// CHECK: @constinit ={{.*}} addrspace(2) constant [5 x i32] [i32 42, i32 43, i32 44, i32 45, i32 46]28 29// CHECK: call spir_func void @_ZNU3AS26MyTypeC1Ei(ptr addrspace(2) {{[^,]*}} @const1, i32 noundef 1)30// CHECK: call spir_func void @_ZNU3AS26MyTypeC1Ei(ptr addrspace(2) {{[^,]*}} @const2, i32 noundef 2)31// CHECK: call spir_func void @_ZNU3AS46MyTypeC1Ei(ptr addrspace(4) {{[^,]*}} addrspacecast (ptr addrspace(1) @glob to ptr addrspace(4)), i32 noundef 1)32 33// CHECK-LABEL: define{{.*}} spir_kernel void @fooGlobal()34kernel void fooGlobal() {35  // CHECK: call spir_func noundef i32 @_ZNU3AS46MyType3barEv(ptr addrspace(4) {{[^,]*}} addrspacecast (ptr addrspace(1) @glob to ptr addrspace(4)))36  glob.bar();37  // CHECK: call spir_func noundef i32 @_ZNU3AS26MyType3barEv(ptr addrspace(2) {{[^,]*}} @const1)38  const1.bar();39  // CHECK: call spir_func void @_ZNU3AS26MyTypeD1Ev(ptr addrspace(2) {{[^,]*}} @const1)40  const1.~MyType();41}42 43// CHECK-LABEL: define{{.*}} spir_kernel void @fooLocal()44kernel void fooLocal() {45  // CHECK: [[VAR:%.*]] = alloca %struct.MyType46  // CHECK: [[REG:%.*]] ={{.*}} addrspacecast ptr [[VAR]] to ptr addrspace(4)47  // CHECK: call spir_func void @_ZNU3AS46MyTypeC1Ei(ptr addrspace(4) {{[^,]*}} [[REG]], i32 noundef 3)48  MyType myLocal(3);49  // CHECK: [[REG:%.*]] ={{.*}} addrspacecast ptr [[VAR]] to ptr addrspace(4)50  // CHECK: call spir_func noundef i32 @_ZNU3AS46MyType3barEv(ptr addrspace(4) {{[^,]*}} [[REG]])51  myLocal.bar();52  // CHECK: [[REG:%.*]] ={{.*}} addrspacecast ptr [[VAR]] to ptr addrspace(4)53  // CHECK: call spir_func void @_ZNU3AS46MyTypeD1Ev(ptr addrspace(4) {{[^,]*}} [[REG]])54}55 56// Ensure all members are defined for all the required address spaces.57// CHECK-DEFINITIONS-DAG: define linkonce_odr spir_func void @_ZNU3AS26MyTypeC1Ei(ptr addrspace(2) {{[^,]*}} %this, i32 noundef %i)58// CHECK-DEFINITIONS-DAG: define linkonce_odr spir_func void @_ZNU3AS46MyTypeC1Ei(ptr addrspace(4) {{[^,]*}} %this, i32 noundef %i)59// CHECK-DEFINITIONS-DAG: define linkonce_odr spir_func void @_ZNU3AS26MyTypeD1Ev(ptr addrspace(2) {{[^,]*}} %this)60// CHECK-DEFINITIONS-DAG: define linkonce_odr spir_func void @_ZNU3AS46MyTypeD1Ev(ptr addrspace(4) {{[^,]*}} %this)61// CHECK-DEFINITIONS-DAG: define linkonce_odr spir_func noundef i32 @_ZNU3AS26MyType3barEv(ptr addrspace(2) {{[^,]*}} %this)62// CHECK-DEFINITIONS-DAG: define linkonce_odr spir_func noundef i32 @_ZNU3AS46MyType3barEv(ptr addrspace(4) {{[^,]*}} %this)63