================
@@ -0,0 +1,97 @@
+; Tests the clang-sycl-linker tool.
+;
+; REQUIRES: spirv-registered-target
+;
+; RUN: rm -rf %t && split-file %s %t
+; RUN: llvm-as %t/input1.ll -o %t/input1.bc
+; RUN: llvm-as %t/input2.ll -o %t/input2.bc
+;
+; Test the dry run of a simple case to link two input files.
+; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 %t/input1.bc
%t/input2.bc -o %t/spirv.out 2>&1 \
+; RUN: | FileCheck %s --check-prefix=SIMPLE-FO
+; SIMPLE-FO: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles:
output: [[LLVMLINKOUT:.*]].bc
+; SIMPLE-FO-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output:
[[LLVMLINKOUT]].bc, mode: none
+; SIMPLE-FO-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: {{.*}}_0.spv
+;
+; Test that IMG_SPIRV image kind is set for non-AOT compilation.
+; RUN: llvm-objdump --offloading %t/spirv.out | FileCheck %s
--check-prefix=IMAGE-KIND-SPIRV
+; IMAGE-KIND-SPIRV: kind spir-v
+;
+; Test the dry run of a simple case with device library files specified.
+; RUN: mkdir -p %t/libs
+; RUN: touch %t/libs/lib1.bc
+; RUN: touch %t/libs/lib2.bc
+; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 %t/input1.bc
%t/input2.bc --library-path=%t/libs --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1
\
+; RUN: | FileCheck %s --check-prefix=DEVLIBS
+; DEVLIBS: sycl-device-link: inputs: {{.*}}.bc libfiles: {{.*}}lib1.bc,
{{.*}}lib2.bc output: [[LLVMLINKOUT:.*]].bc
+; DEVLIBS-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output:
[[LLVMLINKOUT]].bc, mode: none
+; DEVLIBS-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output: a_0.spv
+;
+; Test a simple case with a random file (not bitcode) as input.
+; RUN: touch %t/dummy.o
+; RUN: not clang-sycl-linker -triple=spirv64 %t/dummy.o -o a.spv 2>&1 \
+; RUN: | FileCheck %s --check-prefix=FILETYPEERROR
+; FILETYPEERROR: Unsupported file type
+;
+; Test to see if device library related errors are emitted.
+; RUN: not clang-sycl-linker --dry-run -triple=spirv64 %t/input1.bc
%t/input2.bc --library-path=%t/libs --device-libs= -o a.spv 2>&1 \
+; RUN: | FileCheck %s --check-prefix=DEVLIBSERR1
+; DEVLIBSERR1: Number of device library files cannot be zero
+; RUN: not clang-sycl-linker --dry-run -triple=spirv64 %t/input1.bc
%t/input2.bc --library-path=%t/libs --device-libs=lib1.bc,lib2.bc,lib3.bc -o
a.spv 2>&1 \
+; RUN: | FileCheck %s --check-prefix=DEVLIBSERR2
+; DEVLIBSERR2: '{{.*}}lib3.bc' SYCL device library file is not found
+;
+; Test AOT compilation for an Intel GPU.
+; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 -arch=bmg_g21
%t/input1.bc %t/input2.bc -o %t/aot-gpu.out 2>&1 \
+; RUN: --ocloc-options="-a -b" \
+; RUN: | FileCheck %s --check-prefix=AOT-INTEL-GPU
+; AOT-INTEL-GPU: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles:
output: [[LLVMLINKOUT:.*]].bc
+; AOT-INTEL-GPU-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output:
[[LLVMLINKOUT]].bc, mode: none
+; AOT-INTEL-GPU-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output:
[[SPIRVTRANSLATIONOUT:.*]]_0.spv
+; AOT-INTEL-GPU-NEXT: "{{.*}}ocloc{{.*}}" {{.*}}-device bmg_g21 -a -b
{{.*}}-output [[SPIRVTRANSLATIONOUT]]_0.out -file [[SPIRVTRANSLATIONOUT]]_0.spv
+;
+; Test that IMG_Object image kind is set for AOT compilation (Intel GPU).
+; RUN: llvm-objdump --offloading %t/aot-gpu.out | FileCheck %s
--check-prefix=IMAGE-KIND-OBJECT
+; IMAGE-KIND-OBJECT: kind elf
+;
+; Test AOT compilation for an Intel CPU.
+; RUN: clang-sycl-linker --dry-run -v -triple=spirv64 -arch=graniterapids
%t/input1.bc %t/input2.bc -o %t/aot-cpu.out 2>&1 \
+; RUN: --opencl-aot-options="-a -b" \
+; RUN: | FileCheck %s --check-prefix=AOT-INTEL-CPU
+; AOT-INTEL-CPU: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles:
output: [[LLVMLINKOUT:.*]].bc
+; AOT-INTEL-CPU-NEXT: sycl-module-split: input: [[LLVMLINKOUT]].bc, output:
[[LLVMLINKOUT]].bc, mode: none
+; AOT-INTEL-CPU-NEXT: LLVM backend: input: [[LLVMLINKOUT]].bc, output:
[[SPIRVTRANSLATIONOUT:.*]]_0.spv
+; AOT-INTEL-CPU-NEXT: "{{.*}}opencl-aot{{.*}}" {{.*}}--device=cpu -a -b
{{.*}}-o [[SPIRVTRANSLATIONOUT]]_0.out [[SPIRVTRANSLATIONOUT]]_0.spv
+;
+; Test that IMG_Object image kind is set for AOT compilation (Intel CPU).
+; RUN: llvm-objdump --offloading %t/aot-cpu.out | FileCheck %s
--check-prefix=IMAGE-KIND-OBJECT
+;
+; Check that the output file must be specified.
+; RUN: not clang-sycl-linker --dry-run %t/input1.bc %t/input2.bc 2>&1 \
+; RUN: | FileCheck %s --check-prefix=NOOUTPUT
+; NOOUTPUT: Output file must be specified
+;
+; Check that the target triple must be specified.
----------------
YuriPlyakhin wrote:
not the purpose of this PR. I will consider updating it in the new PR.
https://github.com/llvm/llvm-project/pull/197566
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits