Skip to content

Commit 42c4027

Browse files
authored
[AMDGPU][SplitModule] Keep looking for more dependencies after finding an indirect call (#93480)
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.
1 parent 0e73bbd commit 42c4027

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ static void addAllDependencies(SplitModuleLogger &SML, const CallGraph &CG,
340340
// TODO: Print an ORE as well ?
341341
addAllIndirectCallDependencies(M, Fns);
342342
HadIndirectCall = true;
343-
return;
343+
continue;
344344
}
345345

346346
if (Callee->isDeclaration())

llvm/test/tools/llvm-split/AMDGPU/kernels-dependency-indirect.ll

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@
1010
; We default to putting A/B in P0, alongside a copy
1111
; of all helpers who have their address taken.
1212
; The other kernels can still go into separate partitions.
13+
;
14+
; Note that dependency discovery shouldn't stop upon finding an
15+
; indirect call. HelperC/D should also end up in P0 as they
16+
; are dependencies of HelperB.
1317

1418
; CHECK0-NOT: define
1519
; CHECK0: define hidden void @HelperA
1620
; CHECK0: define hidden void @HelperB
1721
; CHECK0: define hidden void @CallCandidate
18-
; CHECK0-NOT: define {{.*}} @HelperC
19-
; CHECK0-NOT: define {{.*}} @HelperD
22+
; CHECK0: define internal void @HelperC
23+
; CHECK0: define internal void @HelperD
2024
; CHECK0: define amdgpu_kernel void @A
2125
; CHECK0: define amdgpu_kernel void @B
2226
; CHECK0-NOT: define
@@ -39,7 +43,9 @@ define internal void @HelperA(ptr %call) {
3943
}
4044

4145
define internal void @HelperB(ptr %call) {
46+
call void @HelperC()
4247
call void %call()
48+
call void @HelperD()
4349
ret void
4450
}
4551

0 commit comments

Comments
 (0)