[AMDGPU] Review intrinsic flags for `int_amdgcn_s_sendmsg`
This intrinsic and others in the immediate area are not setting the IntrNoCallback flag. Not having this intrinsic prevents PostOrderFunctionAttrsPass from marking a function that uses the intrinsic from having the norecurse flag applied. Ultimately, that then causes the amdhsa_uses_dynamic_stack flag to be set for the kernel.
The use case for this is in our implementation of print() for Mojo that uses the intrinsic to build a native hostcall() implementation. Fixing the intrinsic to have this flag set fixes the problem locally. Other intrinsics such as int_amdgcn_s_sleep do not have the same problem because they derive from DefaultAttrsIntrinsic. Other options are likely available in our LLVM pipeline config, but fixing the intrinsic so far has been the easiest path.
cc: @arsenm
@llvm/issue-subscribers-backend-amdgpu
Author: Tracy Sharpe (raiseirql)
The use case for this is in our implementation of print() for Mojo that uses the intrinsic to build a native hostcall() implementation. Fixing the intrinsic to have this flag set fixes the problem locally. Other intrinsics such as int_amdgcn_s_sleep do not have the same problem because they derive from DefaultAttrsIntrinsic. Other options are likely available in our LLVM pipeline config, but fixing the intrinsic so far has been the easiest path.
cc: @arsenm
I'm not sure we can do this unconditionally. You can use sendmsg to cause code to execute on the host. We might be able to analyze the specific field values used to set a callsite attribute
I'm not sure we can do this unconditionally. You can use sendmsg to cause code to execute on the host. We might be able to analyze the specific field values used to set a callsite attribute
Yeah, the specific case is to do the hostcall based on https://github.com/ROCm/llvm-project/blob/656552edc693e2bb4abc9258399c39d190fce2b3/amd/device-libs/ockl/src/hostcall_impl.cl#L57.
Since the implementation there is OpenCL anyway, norecurse is assumed. I guess that doesn't make it to the intrinsic callsite, and gets lost when the original function is inlined?
In our use case, the hostcall_impl.cl code has been reimplemented in Mojo to avoid link/dependency issues. I imagine there are changes in marking the wrappers as norecurse to fix the problem, but I also wanted to open this issue in case there was a problem with the intrinsic itself.
I don't think we can mark this with nocallback, or nosync. But I think we can directly mark it with norecurse and willreturn. However, tablegen does not currently have an IntrinsicProperty wired up to directly represent norecurse