Skip to content

Commit

Permalink
[AMDGPU][SplitModule] Keep looking for more dependencies after findin…
Browse files Browse the repository at this point in the history
…g an indirect call (llvm#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.
  • Loading branch information
Pierre-vh authored May 28, 2024
1 parent 0e73bbd commit 42c4027
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/AMDGPUSplitModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 8 additions & 2 deletions llvm/test/tools/llvm-split/AMDGPU/kernels-dependency-indirect.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down

0 comments on commit 42c4027

Please sign in to comment.