File: force-alwaysinline-lds-global-address.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (97 lines) | stat: -rw-r--r-- 3,712 bytes parent folder | download | duplicates (4)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-stress-function-calls -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s
; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-stress-function-calls -passes=amdgpu-always-inline -amdgpu-enable-lower-module-lds=false %s | FileCheck --check-prefix=ALL %s

target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"

@lds0 = addrspace(3) global i32 undef, align 4
@lds1 = addrspace(3) global [512 x i32] undef, align 4
@nested.lds.address = addrspace(1) global ptr addrspace(3) @lds0, align 4
@gds0 = addrspace(2) global i32 undef, align 4

@alias.lds0 = alias i32, ptr addrspace(3) @lds0
@lds.cycle = addrspace(3) global i32 ptrtoint (ptr addrspace(3) @lds.cycle to i32), align 4


; ALL-LABEL: define i32 @load_lds_simple() #0 {
define i32 @load_lds_simple() {
  %load = load i32, ptr addrspace(3) @lds0, align 4
  ret i32 %load
}

; ALL-LABEL: define i32 @load_gds_simple() #0 {
define i32 @load_gds_simple() {
  %load = load i32, ptr addrspace(2) @gds0, align 4
  ret i32 %load
}

; ALL-LABEL: define i32 @load_lds_const_gep() #0 {
define i32 @load_lds_const_gep() {
  %load = load i32, ptr addrspace(3) getelementptr inbounds ([512 x i32], ptr addrspace(3) @lds1, i64 0, i64 4), align 4
  ret i32 %load
}

; ALL-LABEL: define i32 @load_lds_var_gep(i32 %idx) #0 {
define i32 @load_lds_var_gep(i32 %idx) {
  %gep = getelementptr inbounds [512 x i32], ptr addrspace(3) @lds1, i32 0, i32 %idx
  %load = load i32, ptr addrspace(3) %gep, align 4
  ret i32 %load
}

; ALL-LABEL: define ptr addrspace(3) @load_nested_address(i32 %idx) #0 {
define ptr addrspace(3) @load_nested_address(i32 %idx) {
  %load = load ptr addrspace(3), ptr addrspace(1) @nested.lds.address, align 4
  ret ptr addrspace(3) %load
}

; ALL-LABEL: define i32 @load_lds_alias() #0 {
define i32 @load_lds_alias() {
  %load = load i32, ptr addrspace(3) @alias.lds0, align 4
  ret i32 %load
}

; ALL-LABEL: define i32 @load_lds_cycle() #0 {
define i32 @load_lds_cycle() {
  %load = load i32, ptr addrspace(3) @lds.cycle, align 4
  ret i32 %load
}

; ALL-LABEL: define i1 @icmp_lds_address() #0 {
define i1 @icmp_lds_address() {
  %cmp = icmp eq ptr addrspace(3) @lds0, null
  ret i1 %cmp
}

; ALL-LABEL: define i32 @transitive_call() #0 {
define i32 @transitive_call() {
  %call = call i32 @load_lds_simple()
  ret i32 %call
}

; ALL-LABEL: define i32 @recursive_call_lds(i32 %arg0) #0 {
define i32 @recursive_call_lds(i32 %arg0) {
  %load = load i32, ptr addrspace(3) @lds0, align 4
  %add = add i32 %arg0, %load
  %call = call i32 @recursive_call_lds(i32 %add)
  ret i32 %call
}

; Test we don't break the IR and have both alwaysinline and noinline
; FIXME: We should really not override noinline.

; ALL-LABEL: define i32 @load_lds_simple_noinline() #0 {
define i32 @load_lds_simple_noinline() noinline {
  %load = load i32, ptr addrspace(3) @lds0, align 4
  ret i32 %load
}

; ALL-LABEL: define i32 @recursive_call_lds_noinline(i32 %arg0) #0 {
define i32 @recursive_call_lds_noinline(i32 %arg0) noinline {
  %load = load i32, ptr addrspace(3) @lds0, align 4
  %add = add i32 %arg0, %load
  %call = call i32 @recursive_call_lds(i32 %add)
  ret i32 %call
}

; ALL: attributes #0 = { alwaysinline }