[llvm] [AMDGPU] Add support for preloading implicit kernel arguments (PR #83817)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 26 05:37:49 PDT 2024


================
@@ -64,6 +64,86 @@ class PreloadKernelArgInfo {
     NumFreeUserSGPRs -= (NumPreloadSGPRs + PaddingSGPRs);
     return true;
   }
+
+  // Try to allocate SGPRs to preload implicit kernel arguments.
+  void tryAllocImplicitArgPreloadSGPRs(unsigned ImplicitArgsBaseOffset,
+                                       IRBuilder<> &Builder) {
+    IntrinsicInst *ImplicitArgPtr = nullptr;
+    for (Function::iterator B = F.begin(), BE = F.end(); B != BE; ++B) {
+      for (BasicBlock::iterator I = B->begin(), IE = B->end(); I != IE; ++I) {
+        if (IntrinsicInst *CI = dyn_cast<IntrinsicInst>(I))
+          if (CI->getIntrinsicID() == Intrinsic::amdgcn_implicitarg_ptr) {
----------------
arsenm wrote:

Instead of scanning the entire function, can you look for uses of the declaration? There should be many and you can check if the parent is the same function 

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


More information about the llvm-commits mailing list