[llvm] [AMDGPU] Strengthen preload intrinsics to noundef and nonnull (PR #92801)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon May 20 12:49:43 PDT 2024


arsenm wrote:

> @arsenm Good to know about the kernarg pointer being potentially null, but also, do you have information about when those cases arise? (I suppose in the case where there are no arguments the kernarg pointer is null, but

Yes 

>  ... why would someone be accessing the kernarg pointer when there are no arguments there?)

Because you don't know the kernel you are being called from in an arbitrary function. You would only know that if you are inlined into the kernel, so some leaf function would have to see null. We redefined it at some point to only allow this in kernels, and use it as an implementation detail in AMDGPULowerKernelArguments. User code is only allowed to use the implicitarg.ptr, which has the same issue. I see there's a test for the 0 sized implicitarg.ptr case returning null, but I don't actually see where that's handled right now.

So we're still left with the question if we can and should support library code that can null check if implicit args are available or not 



> Re the ranges, I was going to either do or file a ticket about updating `AMDGPULowerKernelMetadata` to apply `!range` up in the frontend. And now that I've taken a look around for this new range attribute ... I assume what you're wanting is the conservative, calling-convention-independent upper bound in the intrinsic definition?

Yes. Also, the more specific range metadata can now be replaced with the callsite attribute 

https://github.com/llvm/llvm-project/pull/92801


More information about the llvm-commits mailing list