1 // RUN: %Slang %s 2 3 // RUN: %rs-filecheck-wrapper %s --check-prefix=CHECK-SET 4 // Check rsSetObject() calls are properly added. 5 6 // CHECK-SET-NOT: call void @_Z11rsSetObject{{.*}}({{.*}} %.rs.param.a{{[02]}}, {{.*}}) 7 // CHECK-SET: call void @_Z11rsSetObjectP10rs_elementS_(%struct.rs_element{{.*}}* nonnull %.rs.param.a1, {{.*}}) 8 // CHECK-SET-NOT: call void @_Z11rsSetObject{{.*}}({{.*}} %.rs.param.a{{[02]}}, {{.*}}) 9 10 // CHECK-SET: %[[F1:[A-Za-z][A-Za-z0-9]*]] = getelementptr inbounds %struct.Wrapper{{.*}}, %struct.Wrapper{{.*}}* %.rs.param.a3, i{{(32|64)}} 0, i32 0 11 // CHECK-SET-NOT: call void @_Z11rsSetObject{{.*}}({{.*}} %.rs.param.a{{[02]}}, {{.*}}) 12 // CHECK-SET: call void @_Z11rsSetObjectP13rs_allocationS_(%struct.rs_allocation{{.*}}* %[[F1]], {{.*}}) 13 // CHECK-SET-NOT: call void @_Z11rsSetObject{{.*}}({{.*}} %.rs.param.a{{[02]}}, {{.*}}) 14 // CHECK-SET: %[[F2:[A-Za-z][A-Za-z0-9]*]] = getelementptr inbounds %struct.Wrapper{{.*}}, %struct.Wrapper{{.*}}* %.rs.param.a3, i{{(32|64)}} 0, i32 1 15 // CHECK-SET-NOT: call void @_Z11rsSetObject{{.*}}({{.*}} %.rs.param.a{{[02]}}, {{.*}}) 16 // CHECK-SET: call void @_Z11rsSetObjectP7rs_typeS_(%struct.rs_type{{.*}}* %[[F2]], {{.*}}) 17 // CHECK-SET-NOT: call void @_Z11rsSetObject{{.*}}({{.*}} %.rs.param.a{{[02]}}, {{.*}}) 18 19 // RUN: %rs-filecheck-wrapper %s --check-prefix=CHECK-CLR 20 // Check rsClearObject() calls are properly added. 21 22 // CHECK-CLR-DAG: %[[F10:[A-Za-z][A-Za-z0-9\.]*]] = getelementptr inbounds %struct.Wrapper{{.*}}, %struct.Wrapper{{.*}}* %a3, i{{(32|64)}} 0, i32 0 23 // CHECK-CLR-DAG: %[[F20:[A-Za-z][A-Za-z0-9\.]*]] = getelementptr inbounds %struct.Wrapper{{.*}}, %struct.Wrapper{{.*}}* %a3, i{{(32|64)}} 0, i32 1 24 25 // CHECK-CLR-NOT: call void @_Z13rsClearObject{{.*}}({{.*}}* %.rs.param.a{{[02]}}) 26 // CHECK-CLR: call void @_Z13rsClearObjectP10rs_element(%struct.rs_element{{.*}}* nonnull %x) 27 // CHECK-CLR-NOT: call void @_Z13rsClearObject{{.*}}({{.*}}* %.rs.param.a{{[02]}}) 28 // CHECK-CLR: call void @_Z13rsClearObjectP10rs_element(%struct.rs_element{{.*}}* {{.*}}%a1) 29 // CHECK-CLR-NOT: call void @_Z13rsClearObject{{.*}}({{.*}}* %.rs.param.a{{[02]}}) 30 // CHECK-CLR: call void @_Z13rsClearObjectP13rs_allocation(%struct.rs_allocation{{.*}}* %[[F10]]) 31 // CHECK-CLR-NOT: call void @_Z13rsClearObject{{.*}}({{.*}}* %.rs.param.a{{[02]}}) 32 // CHECK-CLR: call void @_Z13rsClearObjectP7rs_type(%struct.rs_type{{.*}}* %[[F20]]) 33 // CHECK-CLR-NOT: call void @_Z13rsClearObject{{.*}}({{.*}}* %.rs.param.a{{[02]}}) 34 35 #pragma version(1) 36 #pragma rs java_package_name(ref_count) 37 38 static int g0; 39 static float g2; 40 41 struct Wrapper { 42 rs_allocation f1; 43 rs_type f2; 44 int f3; 45 }; 46 47 static void bar(int a0, rs_element a1, float a2, struct Wrapper a3) { 48 rs_element x = {0}; 49 struct Wrapper y = {0}; 50 g0 = a0; 51 a1 = x; 52 g2 = a2; 53 a3 = y; 54 } 55 56 void entrypoint() { 57 rs_element e = {0}; 58 struct Wrapper w = {0}; 59 bar(3, e, 2.718f, w); 60 if (rsIsObject(e) && rsIsObject(w.f1) && rsIsObject(w.f2)) { 61 rsDebug("good objects", 0); 62 } 63 } 64 65 66