File: lower-indirect-lds-references.ll

package info (click to toggle)
llvm-toolchain-21 1%3A21.1.6-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,245,028 kB
  • sloc: cpp: 7,619,726; ansic: 1,434,018; asm: 1,058,748; python: 252,740; f90: 94,671; objc: 70,685; lisp: 42,813; pascal: 18,401; sh: 8,601; ml: 5,111; perl: 4,720; makefile: 3,675; awk: 3,523; javascript: 2,409; xml: 892; fortran: 770
file content (45 lines) | stat: -rw-r--r-- 1,596 bytes parent folder | download | duplicates (3)
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: }