1 ; RUN: opt -O0 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPTNONE %s
2 ; RUN: opt -passes='default<O0>' -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPTNONE %s
3 ; RUN: opt -O1 -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPT %s
4 ; RUN: opt -passes='default<O1>' -S -mtriple=amdgcn-unknown-amdhsa -amdgpu-internalize-symbols < %s | FileCheck -check-prefix=ALL -check-prefix=OPT %s
8 @gvar_unused = addrspace(1) global i32 undef, align 4
11 @gvar_used = addrspace(1) global i32 undef, align 4
13 ; OPT: define internal fastcc void @func_used_noinline(
14 ; OPT-NONE: define fastcc void @func_used_noinline(
15 define fastcc void @func_used_noinline(ptr addrspace(1) %out, i32 %tid) #1 {
17 store volatile i32 %tid, ptr addrspace(1) %out
21 ; OPTNONE: define fastcc void @func_used_alwaysinline(
22 ; OPT-NOT: @func_used_alwaysinline
23 define fastcc void @func_used_alwaysinline(ptr addrspace(1) %out, i32 %tid) #2 {
25 store volatile i32 %tid, ptr addrspace(1) %out
29 ; OPTNONE: define void @func_unused(
30 ; OPT-NOT: @func_unused
31 define void @func_unused(ptr addrspace(1) %out, i32 %tid) #1 {
33 store volatile i32 %tid, ptr addrspace(1) %out
37 ; ALL: define amdgpu_kernel void @kernel_unused(
38 define amdgpu_kernel void @kernel_unused(ptr addrspace(1) %out) #1 {
40 store volatile i32 1, ptr addrspace(1) %out
44 ; ALL: define amdgpu_kernel void @main_kernel()
45 ; ALL: tail call i32 @llvm.amdgcn.workitem.id.x
46 ; ALL: tail call fastcc void @func_used_noinline
49 define amdgpu_kernel void @main_kernel() {
51 %tid = tail call i32 @llvm.amdgcn.workitem.id.x()
52 tail call fastcc void @func_used_noinline(ptr addrspace(1) @gvar_used, i32 %tid)
53 tail call fastcc void @func_used_alwaysinline(ptr addrspace(1) @gvar_used, i32 %tid)
57 declare i32 @llvm.amdgcn.workitem.id.x() #0
59 attributes #0 = { nounwind readnone }
60 attributes #1 = { noinline nounwind }
61 attributes #2 = { alwaysinline nounwind }