[MachineScheduler] Fix physreg dependencies of ExitSU (#123541)
[llvm-project.git] / llvm / test / CodeGen / AMDGPU / lower-indirect-lds-references.ll
blob1b0c8d66d3ebc78dc0fd7d62a1c743db0d926326
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()
15   ret void
18 define void @call_unknown() {
19   %1 = alloca ptr, align 8
20   %2 = call i32 %1()
21   ret void
24 define void @indirectly_load_lds() {
25   call void @directly_load_lds()
26   ret void
29 define void @directly_load_lds() {
30   %2 = load ptr, ptr addrspace(3) @lds_item_to_indirectly_load, align 8
31   ret void
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()
40 ; CHECK: }
42 ; CHECK: define void @directly_load_lds() {
43 ; CHECK:   load ptr, {{.*}} (%[[LDS_STRUCT_TY]], {{.*}} @[[LDS_STRUCT]], i32 0, i32 1)
44 ; CHECK: }