1; RUN: rs2spirv_lit_driver.sh %s | FileCheck %s
2; Source:
3; rs_allocation g;
4; int32_t RS_KERNEL getDim(int32_t dummy) {
5;    return rsAllocationGetDimX(g);
6; }
7target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8target triple = "aarch64-none-linux-gnueabi"
9
10; CHECK: OpString "{\"__RSoV_GA\": {\"g\":0}}"
11; CHECK: OpMemberDecorate [[MetadataS:%[a-zA-Z_0-9]*]] 0 Offset 4
12; CHECK: OpMemberDecorate [[MetadataS]] 1 Offset 8
13; CHECK: OpMemberDecorate [[MetadataS]] 2 Offset 12
14; CHECK: OpMemberDecorate [[MetadataS]] 3 Offset 16
15; CHECK: OpDecorate [[RuntimeArrS:%[a-zA-Z_0-9]*]] ArrayStride {{[0-9]*}}
16; CHECK: OpDecorate [[MetadataSSBO:%[a-zA-Z_0-9]*]] BufferBlock
17; CHECK: OpDecorate [[Metadata:%[a-zA-Z_0-9]*]] DescriptorSet 0
18; CHECK: OpDecorate [[Metadata]] Binding 1
19
20%struct.rs_allocation.1 = type { i64*, i64*, i64*, i64* }
21
22@g = common global %struct.rs_allocation.1 zeroinitializer, align 8
23; CHECK-NOT: %g = OpVariable %{{.*}} Uniform
24; CHECK-NOT: OpCopyMemorySized
25; CHECK-NOT: OpFunctionCall %uint %__rsov_rsAllocationGetDimX
26; CHECK: [[DimX:%[a-zA-Z_0-9]*]] = OpAccessChain %_ptr_Uniform_uint [[Metadata]]
27; CHECK: [[Res:%[a-zA-Z_0-9]*]] = OpLoad %uint [[DimX]]
28; CHECK: OpReturnValue [[Res]]
29
30; Function Attrs: nounwind
31define i32 @getDim(i32 %dummy) unnamed_addr #0 {
32entry:
33  %tmp = alloca %struct.rs_allocation.1, align 8
34  %0 = bitcast %struct.rs_allocation.1* %tmp to i8*
35  call void @llvm.memcpy.p0i8.p0i8.i64(i8* %0, i8* bitcast (%struct.rs_allocation.1* @g to i8*), i64 32, i32 8, i1 false), !tbaa.struct !8
36  %call = call i32 @_Z19rsAllocationGetDimX13rs_allocation(%struct.rs_allocation.1* %tmp) #0
37  ret i32 %call
38}
39
40declare i32 @_Z19rsAllocationGetDimX13rs_allocation(%struct.rs_allocation.1*) unnamed_addr
41
42; Function Attrs: argmemonly nounwind
43declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1
44
45; Function Attrs: nounwind
46define void @.rs.dtor() unnamed_addr #0 {
47entry:
48  tail call void @_Z13rsClearObjectP13rs_allocation(%struct.rs_allocation.1* @g) #0
49  ret void
50}
51
52declare void @_Z13rsClearObjectP13rs_allocation(%struct.rs_allocation.1*) unnamed_addr
53
54attributes #0 = { nounwind }
55attributes #1 = { argmemonly nounwind }
56
57!llvm.ident = !{!0}
58!\23pragma = !{!1, !2}
59!\23rs_export_var = !{!3}
60!\23rs_object_slots = !{!4}
61!\23rs_export_foreach_name = !{!5, !6}
62!\23rs_export_foreach = !{!4, !7}
63
64!0 = !{!"Android clang version 3.8.275480  (based on LLVM 3.8.275480)"}
65!1 = !{!"version", !"1"}
66!2 = !{!"java_package_name", !"com.android.rs.rsov.test"}
67!3 = !{!"g", !"20"}
68!4 = !{!"0"}
69!5 = !{!"root"}
70!6 = !{!"getDim"}
71!7 = !{!"35"}
72!8 = !{i64 0, i64 8, !9, i64 8, i64 8, !9, i64 16, i64 8, !9, i64 24, i64 8, !9}
73!9 = !{!10, !10, i64 0}
74!10 = !{!"any pointer", !11, i64 0}
75!11 = !{!"omnipotent char", !12, i64 0}
76!12 = !{!"Simple C/C++ TBAA"}
77