1 ; RUN: opt -O1 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPT %s
2 ; RUN: opt -O0 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPTNONE %s
6 @gvar_unused = addrspace(1) global i32 undef, align 4
9 @gvar_used = addrspace(1) global i32 undef, align 4
11 ; OPT: define internal fastcc void @func_used_noinline(
12 ; OPT-NONE: define fastcc void @func_used_noinline(
13 define fastcc void @func_used_noinline(i32 addrspace(1)* %out, i32 %tid) #1 {
15 store volatile i32 %tid, i32 addrspace(1)* %out
19 ; OPTNONE: define fastcc void @func_used_alwaysinline(
20 ; OPT-NOT: @func_used_alwaysinline
21 define fastcc void @func_used_alwaysinline(i32 addrspace(1)* %out, i32 %tid) #2 {
23 store volatile i32 %tid, i32 addrspace(1)* %out
27 ; OPTNONE: define void @func_unused(
28 ; OPT-NOT: @func_unused
29 define void @func_unused(i32 addrspace(1)* %out, i32 %tid) #1 {
31 store volatile i32 %tid, i32 addrspace(1)* %out
35 ; ALL: define amdgpu_kernel void @kernel_unused(
36 define amdgpu_kernel void @kernel_unused(i32 addrspace(1)* %out) #1 {
38 store volatile i32 1, i32 addrspace(1)* %out
42 ; ALL: define amdgpu_kernel void @main_kernel()
43 ; ALL: tail call i32 @llvm.amdgcn.workitem.id.x
44 ; ALL: tail call fastcc void @func_used_noinline
47 define amdgpu_kernel void @main_kernel() {
49 %tid = tail call i32 @llvm.amdgcn.workitem.id.x()
50 tail call fastcc void @func_used_noinline(i32 addrspace(1)* @gvar_used, i32 %tid)
51 tail call fastcc void @func_used_alwaysinline(i32 addrspace(1)* @gvar_used, i32 %tid)
55 declare i32 @llvm.amdgcn.workitem.id.x() #0
57 attributes #0 = { nounwind readnone }
58 attributes #1 = { noinline nounwind }
59 attributes #2 = { alwaysinline nounwind }