1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: sed 's/CODE_OBJECT_VERSION/400/g' %s | opt -S -mtriple=amdgcn-unknown-unknown -amdgpu-attributor | FileCheck -check-prefixes=CHECK,V4 %s
3 ; RUN: sed 's/CODE_OBJECT_VERSION/500/g' %s | opt -S -mtriple=amdgcn-unknown-unknown -amdgpu-attributor | FileCheck -check-prefixes=CHECK,V5 %s
5 declare ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr() #0
7 declare i32 @llvm.amdgcn.workgroup.id.x() #0
8 declare i32 @llvm.amdgcn.workgroup.id.y() #0
9 declare i32 @llvm.amdgcn.workgroup.id.z() #0
11 declare i32 @llvm.amdgcn.workitem.id.x() #0
12 declare i32 @llvm.amdgcn.workitem.id.y() #0
13 declare i32 @llvm.amdgcn.workitem.id.z() #0
14 declare i32 @llvm.amdgcn.lds.kernel.id() #0
15 declare i64 @llvm.amdgcn.dispatch.id() #0
18 declare ptr addrspace(4) @llvm.amdgcn.dispatch.ptr() #0
19 declare ptr addrspace(4) @llvm.amdgcn.queue.ptr() #0
20 declare ptr addrspace(4) @llvm.amdgcn.kernarg.segment.ptr() #0
22 ; Avoid adding all of these to the output attribute sets
23 define void @use_everything_else() {
24 ; CHECK-LABEL: define {{[^@]+}}@use_everything_else
25 ; CHECK-SAME: () #[[ATTR1:[0-9]+]] {
26 ; CHECK-NEXT: [[VAL0:%.*]] = call i32 @llvm.amdgcn.workitem.id.x()
27 ; CHECK-NEXT: [[VAL1:%.*]] = call i32 @llvm.amdgcn.workitem.id.y()
28 ; CHECK-NEXT: [[VAL2:%.*]] = call i32 @llvm.amdgcn.workitem.id.z()
29 ; CHECK-NEXT: [[VAL3:%.*]] = call i32 @llvm.amdgcn.workgroup.id.x()
30 ; CHECK-NEXT: [[VAL4:%.*]] = call i32 @llvm.amdgcn.workgroup.id.y()
31 ; CHECK-NEXT: [[VAL5:%.*]] = call i32 @llvm.amdgcn.workgroup.id.z()
32 ; CHECK-NEXT: store volatile i32 [[VAL0]], ptr addrspace(1) null, align 4
33 ; CHECK-NEXT: store volatile i32 [[VAL1]], ptr addrspace(1) null, align 4
34 ; CHECK-NEXT: store volatile i32 [[VAL2]], ptr addrspace(1) null, align 4
35 ; CHECK-NEXT: store volatile i32 [[VAL3]], ptr addrspace(1) null, align 4
36 ; CHECK-NEXT: store volatile i32 [[VAL4]], ptr addrspace(1) null, align 4
37 ; CHECK-NEXT: store volatile i32 [[VAL5]], ptr addrspace(1) null, align 4
38 ; CHECK-NEXT: [[DISPATCH_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
39 ; CHECK-NEXT: [[QUEUE_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.queue.ptr()
40 ; CHECK-NEXT: [[VAL6:%.*]] = load volatile ptr, ptr addrspace(4) [[DISPATCH_PTR]], align 8
41 ; CHECK-NEXT: [[VAL7:%.*]] = load volatile ptr, ptr addrspace(4) [[QUEUE_PTR]], align 8
42 ; CHECK-NEXT: [[VAL8:%.*]] = call i32 @llvm.amdgcn.lds.kernel.id()
43 ; CHECK-NEXT: store volatile i32 [[VAL8]], ptr addrspace(1) null, align 4
44 ; CHECK-NEXT: [[VAL9:%.*]] = call i64 @llvm.amdgcn.dispatch.id()
45 ; CHECK-NEXT: store volatile i64 [[VAL9]], ptr addrspace(1) null, align 8
46 ; CHECK-NEXT: ret void
48 %val0 = call i32 @llvm.amdgcn.workitem.id.x()
49 %val1 = call i32 @llvm.amdgcn.workitem.id.y()
50 %val2 = call i32 @llvm.amdgcn.workitem.id.z()
51 %val3 = call i32 @llvm.amdgcn.workgroup.id.x()
52 %val4 = call i32 @llvm.amdgcn.workgroup.id.y()
53 %val5 = call i32 @llvm.amdgcn.workgroup.id.z()
54 store volatile i32 %val0, ptr addrspace(1) null
55 store volatile i32 %val1, ptr addrspace(1) null
56 store volatile i32 %val2, ptr addrspace(1) null
57 store volatile i32 %val3, ptr addrspace(1) null
58 store volatile i32 %val4, ptr addrspace(1) null
59 store volatile i32 %val5, ptr addrspace(1) null
60 %dispatch.ptr = call ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
61 %queue.ptr = call ptr addrspace(4) @llvm.amdgcn.queue.ptr()
62 %val6 = load volatile ptr, ptr addrspace(4) %dispatch.ptr
63 %val7 = load volatile ptr, ptr addrspace(4) %queue.ptr
64 %val8 = call i32 @llvm.amdgcn.lds.kernel.id()
65 store volatile i32 %val8, ptr addrspace(1) null
66 %val9 = call i64 @llvm.amdgcn.dispatch.id()
67 store volatile i64 %val9, ptr addrspace(1) null
71 define amdgpu_kernel void @test_default_queue_offset_v4_0(ptr addrspace(1) %kernarg) {
72 ; CHECK-LABEL: define {{[^@]+}}@test_default_queue_offset_v4_0
73 ; CHECK-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR2:[0-9]+]] {
74 ; CHECK-NEXT: call void @use_everything_else()
75 ; CHECK-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
76 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 32
77 ; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr addrspace(4) [[GEP]], align 8
78 ; CHECK-NEXT: store ptr [[LOAD]], ptr addrspace(1) [[KERNARG]], align 8
79 ; CHECK-NEXT: ret void
81 call void @use_everything_else()
82 %implicitarg.ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
83 %gep = getelementptr inbounds i8, ptr addrspace(4) %implicitarg.ptr, i64 32
84 %load = load ptr, ptr addrspace(4) %gep
85 store ptr %load, ptr addrspace(1) %kernarg
89 define amdgpu_kernel void @test_default_queue_offset_v5_0(ptr addrspace(1) %kernarg) {
90 ; CHECK-LABEL: define {{[^@]+}}@test_default_queue_offset_v5_0
91 ; CHECK-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR3:[0-9]+]] {
92 ; CHECK-NEXT: call void @use_everything_else()
93 ; CHECK-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
94 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 104
95 ; CHECK-NEXT: [[LOAD:%.*]] = load ptr, ptr addrspace(4) [[GEP]], align 8
96 ; CHECK-NEXT: store ptr [[LOAD]], ptr addrspace(1) [[KERNARG]], align 8
97 ; CHECK-NEXT: ret void
99 call void @use_everything_else()
100 %implicitarg.ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
101 %gep = getelementptr inbounds i8, ptr addrspace(4) %implicitarg.ptr, i64 104
102 %load = load ptr, ptr addrspace(4) %gep
103 store ptr %load, ptr addrspace(1) %kernarg
107 define amdgpu_kernel void @test_completion_action_offset_v4_0(ptr addrspace(1) %kernarg) {
108 ; V4-LABEL: define {{[^@]+}}@test_completion_action_offset_v4_0
109 ; V4-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR4:[0-9]+]] {
110 ; V4-NEXT: call void @use_everything_else()
111 ; V4-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
112 ; V4-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 40
113 ; V4-NEXT: [[LOAD:%.*]] = load ptr, ptr addrspace(4) [[GEP]], align 8
114 ; V4-NEXT: store ptr [[LOAD]], ptr addrspace(1) [[KERNARG]], align 8
117 ; V5-LABEL: define {{[^@]+}}@test_completion_action_offset_v4_0
118 ; V5-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR2]] {
119 ; V5-NEXT: call void @use_everything_else()
120 ; V5-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
121 ; V5-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 40
122 ; V5-NEXT: [[LOAD:%.*]] = load ptr, ptr addrspace(4) [[GEP]], align 8
123 ; V5-NEXT: store ptr [[LOAD]], ptr addrspace(1) [[KERNARG]], align 8
126 call void @use_everything_else()
127 %implicitarg.ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
128 %gep = getelementptr inbounds i8, ptr addrspace(4) %implicitarg.ptr, i64 40
129 %load = load ptr, ptr addrspace(4) %gep
130 store ptr %load, ptr addrspace(1) %kernarg
134 define amdgpu_kernel void @test_completion_action_offset_v5_0(ptr addrspace(1) %kernarg) {
135 ; V4-LABEL: define {{[^@]+}}@test_completion_action_offset_v5_0
136 ; V4-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR3]] {
137 ; V4-NEXT: call void @use_everything_else()
138 ; V4-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
139 ; V4-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 112
140 ; V4-NEXT: [[LOAD:%.*]] = load ptr, ptr addrspace(4) [[GEP]], align 8
141 ; V4-NEXT: store ptr [[LOAD]], ptr addrspace(1) [[KERNARG]], align 8
144 ; V5-LABEL: define {{[^@]+}}@test_completion_action_offset_v5_0
145 ; V5-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR4:[0-9]+]] {
146 ; V5-NEXT: call void @use_everything_else()
147 ; V5-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
148 ; V5-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 112
149 ; V5-NEXT: [[LOAD:%.*]] = load ptr, ptr addrspace(4) [[GEP]], align 8
150 ; V5-NEXT: store ptr [[LOAD]], ptr addrspace(1) [[KERNARG]], align 8
153 call void @use_everything_else()
154 %implicitarg.ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
155 %gep = getelementptr inbounds i8, ptr addrspace(4) %implicitarg.ptr, i64 112
156 %load = load ptr, ptr addrspace(4) %gep
157 store ptr %load, ptr addrspace(1) %kernarg
161 define amdgpu_kernel void @test_default_queue_completion_action_offset_v3_0(ptr addrspace(1) %kernarg) {
162 ; V4-LABEL: define {{[^@]+}}@test_default_queue_completion_action_offset_v3_0
163 ; V4-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR5:[0-9]+]] {
164 ; V4-NEXT: call void @use_everything_else()
165 ; V4-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
166 ; V4-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 32
167 ; V4-NEXT: [[LOAD:%.*]] = load <2 x ptr>, ptr addrspace(4) [[GEP]], align 16
168 ; V4-NEXT: store <2 x ptr> [[LOAD]], ptr addrspace(1) [[KERNARG]], align 16
171 ; V5-LABEL: define {{[^@]+}}@test_default_queue_completion_action_offset_v3_0
172 ; V5-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR2]] {
173 ; V5-NEXT: call void @use_everything_else()
174 ; V5-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
175 ; V5-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 32
176 ; V5-NEXT: [[LOAD:%.*]] = load <2 x ptr>, ptr addrspace(4) [[GEP]], align 16
177 ; V5-NEXT: store <2 x ptr> [[LOAD]], ptr addrspace(1) [[KERNARG]], align 16
180 call void @use_everything_else()
181 %implicitarg.ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
182 %gep = getelementptr inbounds i8, ptr addrspace(4) %implicitarg.ptr, i64 32
183 %load = load <2 x ptr>, ptr addrspace(4) %gep
184 store <2 x ptr> %load, ptr addrspace(1) %kernarg
188 define amdgpu_kernel void @test_default_queue_completion_action_offset_v5_0(ptr addrspace(1) %kernarg) {
189 ; V4-LABEL: define {{[^@]+}}@test_default_queue_completion_action_offset_v5_0
190 ; V4-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR3]] {
191 ; V4-NEXT: call void @use_everything_else()
192 ; V4-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
193 ; V4-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 104
194 ; V4-NEXT: [[LOAD:%.*]] = load <2 x ptr>, ptr addrspace(4) [[GEP]], align 16
195 ; V4-NEXT: store <2 x ptr> [[LOAD]], ptr addrspace(1) [[KERNARG]], align 16
198 ; V5-LABEL: define {{[^@]+}}@test_default_queue_completion_action_offset_v5_0
199 ; V5-SAME: (ptr addrspace(1) [[KERNARG:%.*]]) #[[ATTR5:[0-9]+]] {
200 ; V5-NEXT: call void @use_everything_else()
201 ; V5-NEXT: [[IMPLICITARG_PTR:%.*]] = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
202 ; V5-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr addrspace(4) [[IMPLICITARG_PTR]], i64 104
203 ; V5-NEXT: [[LOAD:%.*]] = load <2 x ptr>, ptr addrspace(4) [[GEP]], align 16
204 ; V5-NEXT: store <2 x ptr> [[LOAD]], ptr addrspace(1) [[KERNARG]], align 16
208 call void @use_everything_else()%implicitarg.ptr = call ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
209 %gep = getelementptr inbounds i8, ptr addrspace(4) %implicitarg.ptr, i64 104
210 %load = load <2 x ptr>, ptr addrspace(4) %gep
211 store <2 x ptr> %load, ptr addrspace(1) %kernarg
216 attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
218 !llvm.module.flags = !{!0}
219 !0 = !{i32 1, !"amdgpu_code_object_version", i32 CODE_OBJECT_VERSION}
223 ; V4: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
224 ; V4: attributes #[[ATTR1]] = { "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-multigrid-sync-arg" "amdgpu-waves-per-eu"="4,10" "uniform-work-group-size"="false" }
225 ; V4: attributes #[[ATTR2]] = { "amdgpu-no-completion-action" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
226 ; V4: attributes #[[ATTR3]] = { "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
227 ; V4: attributes #[[ATTR4]] = { "amdgpu-no-default-queue" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
228 ; V4: attributes #[[ATTR5]] = { "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
230 ; V5: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
231 ; V5: attributes #[[ATTR1]] = { "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "amdgpu-waves-per-eu"="4,10" "uniform-work-group-size"="false" }
232 ; V5: attributes #[[ATTR2]] = { "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
233 ; V5: attributes #[[ATTR3]] = { "amdgpu-no-completion-action" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
234 ; V5: attributes #[[ATTR4]] = { "amdgpu-no-default-queue" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
235 ; V5: attributes #[[ATTR5]] = { "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-multigrid-sync-arg" "uniform-work-group-size"="false" }
237 ; V4: [[META0:![0-9]+]] = !{i32 1, !"amdgpu_code_object_version", i32 400}
239 ; V5: [[META0:![0-9]+]] = !{i32 1, !"amdgpu_code_object_version", i32 500}