[llvm] [AMDGPU] Fix hidden kernarg preload count inconsistency (PR #116759)

Austin Kerbow via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 13:25:17 PST 2024


================
@@ -520,6 +520,16 @@ bool AMDGPUCallLowering::lowerFormalArgumentsKernel(
 
   // TODO: Align down to dword alignment and extract bits for extending loads.
   for (auto &Arg : F.args()) {
+    // Hidden arguments that are in the kernel signature must be preloaded to
+    // user SGPRs, or loaded via the implicit_arg ptr. Print a diagnostic error
+    // if a hidden argument is in the argument list and is not preloaded.
+    if (Arg.hasAttribute("amdgpu-hidden-argument")) {
+      DiagnosticInfoUnsupported NonPreloadHiddenArg(
+          *Arg.getParent(),
+          "hidden argument in kernel signature was not preloaded");
+      F.getContext().diagnose(NonPreloadHiddenArg);
+    }
----------------
kerbowa wrote:

We had decided a while back that hidden arguments should not always be in the kernel signature. They will only be present if they are preloaded into user SGPRs. This diagnostic is saying we should never see the attribute in gisel since preloading kernargs isn't implemented there yet, but I'm going to add that support next.

If a hidden argument in the signature and has the attribute `amdgpu-hidden-argument` uses of that argument must use the preloaded SGPR. There is nothing stopping other instances of the same argument from being accessed via the implicit_arg ptr in a callee for example.

We could easily make it so that isel can handle these even if they are not preloaded, but since it is not intended and it indicates a mismatch between isel and `AMDGPULowerKernelArguments` we error out instead.

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


More information about the llvm-commits mailing list