AMDGPU: Fix crashing on calls to C functions from graphics contexts
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 15 Jan 2022 20:12:18 +0000 (15:12 -0500)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Mon, 17 Jan 2022 15:13:25 +0000 (10:13 -0500)
commitdc2457c8cf096b35e3addb7fceb252d90803430f
tree2da8cbddf784ea0121d760153b7ec0ee42aea4a4
parent9392b40d4b1999c9b33490829552d928a2fa9bab
AMDGPU: Fix crashing on calls to C functions from graphics contexts

If we had one of the shader calling conventions calling a default
calling convention callee, this would crash when the caller did not
have anything to pass to the workitem ID.

This is illegal, but we still need to produce something
sensible. llvm-reduce likes to replace calls to intrinsics with calls
to null or undef, so this does appear and is helpful to avoid hard
erroring.

Pass undef in this case, as already happened for the other implicit
arguments. It might make sense to define the behavior here and pass
null for the pointers, and -1 for the workitem ID. We do have extra
bits in the workitem ID, so this wouldn't conflict with a valid value.
llvm/lib/Target/AMDGPU/AMDGPUCallLowering.cpp
llvm/lib/Target/AMDGPU/SIISelLowering.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/irtranslator-call.ll
llvm/test/CodeGen/AMDGPU/amdpal-callable.ll
llvm/test/CodeGen/AMDGPU/gfx-call-non-gfx-func.ll [new file with mode: 0644]