[llvm] AMDGPU: Drop amdgpu-no-lds-kernel-id attribute in LDS lowering (PR #71481)

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 09:01:40 PST 2023


================
@@ -1028,6 +1028,42 @@ class AMDGPULowerModuleLDS {
     return N;
   }
 
+  /// Strip "amdgpu-no-lds-kernel-id" from any functions where we may have
+  /// introduced its use. If AMDGPUAttributor ran prior to the pass, we inferred
+  /// the lack of llvm.amdgcn.lds.kernel.id calls.
+  void removeNoLdsKernelIdFromReachable(CallGraph &CG, Function *KernelRoot) {
+    KernelRoot->removeFnAttr("amdgpu-no-lds-kernel-id");
+
+    SmallVector<Function *> Tmp({CG[KernelRoot]->getFunction()});
+    if (!Tmp.back())
+      return;
+
+    do {
+      Function *F = Tmp.pop_back_val();
+
+      for (auto &N : *CG[F]) {
+        if (!N.second)
+          continue;
+
+        Function *Callee = N.second->getFunction();
+        if (!Callee) {
----------------
jdoerfert wrote:

You only need to do this once, this might visit the external nodes many times. Similarly, this will not handle recursions well.

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


More information about the llvm-commits mailing list