Skip to content

Commit

Permalink
AMDGPU: Fix annotate kernel features through casted calls
Browse files Browse the repository at this point in the history
I thought I was testing this before, but the workitem id x
case isn't great since it's mandatory in the parent kernel.
  • Loading branch information
arsenm committed Apr 5, 2020
1 parent c80cf48 commit 6bfe28e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUAnnotateKernelFeatures.cpp
Expand Up @@ -289,7 +289,8 @@ bool AMDGPUAnnotateKernelFeatures::addFeatureAttributes(Function &F) {
for (Instruction &I : BB) {
CallSite CS(&I);
if (CS) {
Function *Callee = CS.getCalledFunction();
const Function *Callee
= dyn_cast<Function>(CS.getCalledValue()->stripPointerCasts());

// TODO: Do something with indirect calls.
if (!Callee) {
Expand Down
15 changes: 15 additions & 0 deletions llvm/test/CodeGen/AMDGPU/annotate-kernel-features-hsa-call.ll
Expand Up @@ -295,6 +295,20 @@ define amdgpu_kernel void @func_kern_defined() #3 {
ret void
}

; HSA: define i32 @use_dispatch_ptr_ret_type() #20 {
define i32 @use_dispatch_ptr_ret_type() #1 {
%dispatch.ptr = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
store volatile i8 addrspace(4)* %dispatch.ptr, i8 addrspace(4)* addrspace(1)* undef
ret i32 0
}

; HSA: define float @func_indirect_use_dispatch_ptr_constexpr_cast_func() #20 {
define float @func_indirect_use_dispatch_ptr_constexpr_cast_func() #1 {
%f = call float bitcast (i32()* @use_dispatch_ptr_ret_type to float()*)()
%fadd = fadd float %f, 1.0
ret float %fadd
}

attributes #0 = { nounwind readnone speculatable }
attributes #1 = { nounwind "target-cpu"="fiji" }
attributes #2 = { nounwind "target-cpu"="gfx900" }
Expand All @@ -320,3 +334,4 @@ attributes #3 = { nounwind }
; HSA: attributes #17 = { nounwind "uniform-work-group-size"="false" }
; HSA: attributes #18 = { nounwind }
; HSA: attributes #19 = { nounwind "amdgpu-calls" "uniform-work-group-size"="false" }
; HSA: attributes #20 = { nounwind "amdgpu-dispatch-ptr" "target-cpu"="fiji" }

0 comments on commit 6bfe28e

Please sign in to comment.