Maksim Sabianin 3f59a22711
[offload][SYCL] Add Module splitting by categories. (#131347)
This patch adds Module splitting by categories. The splitting algorithm
is the necessary step in the SYCL compilation pipeline. Also it could be
reused for other heterogenous targets.

The previous attempt was at #119713. In this patch there is no
dependency in `TransformUtils` on "IPO" and on "Printing Passes". In
this patch a module splitting is self-contained and it doesn't introduce
linking issues.
2025-08-05 14:04:59 +00:00

39 lines
1.2 KiB
LLVM

; This test checks that Module splitting can properly perform device code split by tracking
; all uses of functions (not only direct calls).
; RUN: llvm-split -split-by-category=module-id -S < %s -o %t
; RUN: FileCheck %s -input-file=%t_0.ll --check-prefix=CHECK-IR0
; RUN: FileCheck %s -input-file=%t_1.ll --check-prefix=CHECK-IR1
; CHECK-IR0: define dso_local spir_kernel void @kernelA
;
; CHECK-IR1: @FuncTable = weak global ptr @func
; CHECK-IR1: define {{.*}} i32 @func
; CHECK-IR1: define weak_odr dso_local spir_kernel void @kernelB
@FuncTable = weak global ptr @func, align 8
define dso_local spir_func i32 @func(i32 %a) {
entry:
ret i32 %a
}
define weak_odr dso_local spir_kernel void @kernelB() #0 {
entry:
%0 = call i32 @indirect_call(ptr addrspace(4) addrspacecast ( ptr getelementptr inbounds ( [1 x ptr] , ptr @FuncTable, i64 0, i64 0) to ptr addrspace(4)), i32 0)
ret void
}
define dso_local spir_kernel void @kernelA() #1 {
entry:
ret void
}
declare dso_local spir_func i32 @indirect_call(ptr addrspace(4), i32) local_unnamed_addr
attributes #0 = { "module-id"="TU1.cpp" }
attributes #1 = { "module-id"="TU2.cpp" }
; CHECK: kernel1
; CHECK: kernel2