1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s | FileCheck %s
; Tests that the LDS lowering pass handles indirect references to LDS GVs; i.e.
; that it lowers to accesses into the generated LDS struct if these references
; are deep in the call graph starting at the kernel.
@lds_item_to_indirectly_load = internal addrspace(3) global ptr poison, align 8
%store_type = type { i32, ptr }
@place_to_store_indirect_caller = internal addrspace(3) global %store_type poison, align 8
define amdgpu_kernel void @offloading_kernel() {
store ptr @indirectly_load_lds, ptr addrspace(3) getelementptr inbounds nuw (i8, ptr addrspace(3) @place_to_store_indirect_caller, i32 0), align 8
call void @call_unknown()
ret void
}
define void @call_unknown() {
%alloca = alloca ptr, align 8, addrspace(5)
%alloca.cast = addrspacecast ptr addrspace(5) %alloca to ptr
%ret = call i32 %alloca.cast()
ret void
}
define void @indirectly_load_lds() {
call void @directly_load_lds()
ret void
}
define void @directly_load_lds() {
%2 = load ptr, ptr addrspace(3) @lds_item_to_indirectly_load, align 8
ret void
}
; CHECK: %[[LDS_STRUCT_TY:.*]] = type { %store_type, ptr }
; CHECK: @[[LDS_STRUCT:.*]] = {{.*}} %[[LDS_STRUCT_TY]] {{.*}} !absolute_symbol
; CHECK: define amdgpu_kernel void @offloading_kernel() {{.*}} {
; CHECK: store ptr @indirectly_load_lds, {{.*}} @[[LDS_STRUCT]]
; CHECK: call void @call_unknown()
; CHECK: }
; CHECK: define void @directly_load_lds() {
; CHECK: load ptr, {{.*}} (%[[LDS_STRUCT_TY]], {{.*}} @[[LDS_STRUCT]], i32 0, i32 1)
; CHECK: }
|