[llvm] [AMDGPU] Add dynamic LDS size implicit kernel argument to CO-v5 (PR #65273)

via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 28 07:13:48 PST 2023


================
@@ -6771,6 +6771,7 @@ SDValue SITargetLowering::LowerGlobalAddress(AMDGPUMachineFunction *MFI,
         // Adjust alignment for that dynamic shared memory array.
         Function &F = DAG.getMachineFunction().getFunction();
         MFI->setDynLDSAlign(F, *cast<GlobalVariable>(GV));
+        MFI->setUsesDynamicLDS(true);
----------------
skc7 wrote:

Thanks for suggestions @arsenm. Have updated the patch to identify below cases:

- Kernel uses dynamic global -> UsesDynamicLDS flag will be set in SITargetLowering::LowerGlobalAddress.
- Dyn lds globals (used in function and not present in parent kernel) are replaced with "llvm.amdgcn.kernel-name.dynlds" after module-lds-lowering pass. So, we can use the existing helper function "getKernelDynLDSGlobalFromFunction" from AMDGPUMachineFunction to identify if kernel uses dynamic LDS.
- LDS passed as pointer argument to kernel -> Will be identified using utility hasLDSKernelArgument.

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


More information about the llvm-commits mailing list