46 lines · plain
1; RUN: opt -S -mtriple=amdgcn-- -passes=amdgpu-lower-module-lds < %s | FileCheck %s2 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 references5; are deep in the call graph starting at the kernel.6 7@lds_item_to_indirectly_load = internal addrspace(3) global ptr poison, align 88 9%store_type = type { i32, ptr }10@place_to_store_indirect_caller = internal addrspace(3) global %store_type poison, align 811 12define 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 814 call void @call_unknown()15 ret void16}17 18define void @call_unknown() {19 %alloca = alloca ptr, align 8, addrspace(5)20 %alloca.cast = addrspacecast ptr addrspace(5) %alloca to ptr21 %ret = call i32 %alloca.cast()22 ret void23}24 25define void @indirectly_load_lds() {26 call void @directly_load_lds()27 ret void28}29 30define void @directly_load_lds() {31 %2 = load ptr, ptr addrspace(3) @lds_item_to_indirectly_load, align 832 ret void33}34 35; CHECK: %[[LDS_STRUCT_TY:.*]] = type { %store_type, ptr }36; CHECK: @[[LDS_STRUCT:.*]] = {{.*}} %[[LDS_STRUCT_TY]] {{.*}} !absolute_symbol37 38; CHECK: define amdgpu_kernel void @offloading_kernel() {{.*}} {39; CHECK: store ptr @indirectly_load_lds, {{.*}} @[[LDS_STRUCT]]40; CHECK: call void @call_unknown()41; CHECK: }42 43; CHECK: define void @directly_load_lds() {44; CHECK: load ptr, {{.*}} (%[[LDS_STRUCT_TY]], {{.*}} @[[LDS_STRUCT]], i32 0, i32 1)45; CHECK: }46