[llvm] [AMDGPU][SplitModule] Keep looking for more dependencies after finding an indirect call (PR #93480)

Pierre van Houtryve via llvm-commits llvm-commits at lists.llvm.org
Mon May 27 23:18:51 PDT 2024


https://github.com/Pierre-vh updated https://github.com/llvm/llvm-project/pull/93480

>From a667d4faaa4eb1f5fbaca16caf468e81139bb5a9 Mon Sep 17 00:00:00 2001
From: pvanhout <pierre.vanhoutryve at amd.com>
Date: Mon, 27 May 2024 16:23:18 +0200
Subject: [PATCH 1/2] [AMDGPU][SplitModule] Keep looking for more dependencies
 after finding an indirect call

This is just something I noticed while going over this pass logic one more time and didn't cause issues (yet).
If we find an indirect call, we stop looking assuming we added all
functions to the list, but if not all functions in the module were
indirectly callable, some may still be missing.

Just to be safe, keep looking until we did everything we could to find dependencies, so we don't accidentally miss one.
---
 llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
index dab773f28752d..2449fa581842a 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
@@ -340,7 +340,7 @@ static void addAllDependencies(SplitModuleLogger &SML, const CallGraph &CG,
         // TODO: Print an ORE as well ?
         addAllIndirectCallDependencies(M, Fns);
         HadIndirectCall = true;
-        return;
+        continue;
       }
 
       if (Callee->isDeclaration())

>From c5541958d924b302bf9bb09369b6489f5ed52c54 Mon Sep 17 00:00:00 2001
From: pvanhout <pierre.vanhoutryve at amd.com>
Date: Tue, 28 May 2024 08:18:39 +0200
Subject: [PATCH 2/2] add testcase

---
 .../llvm-split/AMDGPU/kernels-dependency-indirect.ll   | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/llvm/test/tools/llvm-split/AMDGPU/kernels-dependency-indirect.ll b/llvm/test/tools/llvm-split/AMDGPU/kernels-dependency-indirect.ll
index 9701ac35ce54e..2d870039112cb 100644
--- a/llvm/test/tools/llvm-split/AMDGPU/kernels-dependency-indirect.ll
+++ b/llvm/test/tools/llvm-split/AMDGPU/kernels-dependency-indirect.ll
@@ -10,13 +10,17 @@
 ; We default to putting A/B in P0, alongside a copy
 ; of all helpers who have their address taken.
 ; The other kernels can still go into separate partitions.
+;
+; Note that dependency discovery shouldn't stop upon finding an
+; indirect call. HelperC/D should also end up in P0 as they
+; are dependencies of HelperB.
 
 ; CHECK0-NOT: define
 ; CHECK0: define hidden void @HelperA
 ; CHECK0: define hidden void @HelperB
 ; CHECK0: define hidden void @CallCandidate
-; CHECK0-NOT: define {{.*}} @HelperC
-; CHECK0-NOT: define {{.*}} @HelperD
+; CHECK0: define internal void @HelperC
+; CHECK0: define internal void @HelperD
 ; CHECK0: define amdgpu_kernel void @A
 ; CHECK0: define amdgpu_kernel void @B
 ; CHECK0-NOT: define
@@ -39,7 +43,9 @@ define internal void @HelperA(ptr %call) {
 }
 
 define internal void @HelperB(ptr %call) {
+  call void @HelperC()
   call void %call()
+  call void @HelperD()
   ret void
 }
 



More information about the llvm-commits mailing list