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