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 3 4; OPT-NOT: gvar_unused 5; OPTNONE: gvar_unused 6@gvar_unused = addrspace(1) global i32 undef, align 4 7 8; ALL: gvar_used 9@gvar_used = addrspace(1) global i32 undef, align 4 10 11; ALL: define internal fastcc void @func_used_noinline( 12define fastcc void @func_used_noinline(i32 addrspace(1)* %out, i32 %tid) #1 { 13entry: 14 store volatile i32 %tid, i32 addrspace(1)* %out 15 ret void 16} 17 18; OPTNONE: define internal fastcc void @func_used_alwaysinline( 19; OPT-NOT: @func_used_alwaysinline 20define fastcc void @func_used_alwaysinline(i32 addrspace(1)* %out, i32 %tid) #2 { 21entry: 22 store volatile i32 %tid, i32 addrspace(1)* %out 23 ret void 24} 25 26; OPTNONE: define internal void @func_unused( 27; OPT-NOT: @func_unused 28define void @func_unused(i32 addrspace(1)* %out, i32 %tid) #1 { 29entry: 30 store volatile i32 %tid, i32 addrspace(1)* %out 31 ret void 32} 33 34; ALL: define amdgpu_kernel void @kernel_unused( 35define amdgpu_kernel void @kernel_unused(i32 addrspace(1)* %out) #1 { 36entry: 37 store volatile i32 1, i32 addrspace(1)* %out 38 ret void 39} 40 41; ALL: define amdgpu_kernel void @main_kernel() 42; ALL: tail call i32 @llvm.amdgcn.workitem.id.x 43; ALL: tail call fastcc void @func_used_noinline 44; ALL: store volatile 45; ALL: ret void 46define amdgpu_kernel void @main_kernel() { 47entry: 48 %tid = tail call i32 @llvm.amdgcn.workitem.id.x() 49 tail call fastcc void @func_used_noinline(i32 addrspace(1)* @gvar_used, i32 %tid) 50 tail call fastcc void @func_used_alwaysinline(i32 addrspace(1)* @gvar_used, i32 %tid) 51 ret void 52} 53 54declare i32 @llvm.amdgcn.workitem.id.x() #0 55 56attributes #0 = { nounwind readnone } 57attributes #1 = { noinline nounwind } 58attributes #2 = { alwaysinline nounwind } 59