Debian Codegraph @

clang/test/Driver/clang-sycl-linker-test.cpp

raw
1 // Tests the clang-sycl-linker tool.
2 //
3 // REQUIRES: spirv-registered-target
4 //
5 // Test the dry run of a simple case to link two input files.
6 // RUN: %clangxx -emit-llvm -c -target spirv64 %s -o %t_1.bc
7 // RUN: %clangxx -emit-llvm -c -target spirv64 %s -o %t_2.bc
8 // RUN: clang-sycl-linker --dry-run -v -triple=spirv64 %t_1.bc %t_2.bc -o a.spv 2>&1 \
9 // RUN: | FileCheck %s --check-prefix=SIMPLE-FO
10 // SIMPLE-FO: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc
11 // SIMPLE-FO-NEXT: SPIR-V Backend: input: [[LLVMLINKOUT]].bc, output: a_0.spv
12 //
13 // Test the dry run of a simple case with device library files specified.
14 // RUN: mkdir -p %t.dir
15 // RUN: touch %t.dir/lib1.bc
16 // RUN: touch %t.dir/lib2.bc
17 // RUN: clang-sycl-linker --dry-run -v -triple=spirv64 %t_1.bc %t_2.bc --library-path=%t.dir --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1 \
18 // RUN: | FileCheck %s --check-prefix=DEVLIBS
19 // DEVLIBS: sycl-device-link: inputs: {{.*}}.bc libfiles: {{.*}}lib1.bc, {{.*}}lib2.bc output: [[LLVMLINKOUT:.*]].bc
20 // DEVLIBS-NEXT: SPIR-V Backend: input: [[LLVMLINKOUT]].bc, output: a_0.spv
21 //
22 // Test a simple case with a random file (not bitcode) as input.
23 // RUN: touch %t.o
24 // RUN: not clang-sycl-linker -triple=spirv64 %t.o -o a.spv 2>&1 \
25 // RUN: | FileCheck %s --check-prefix=FILETYPEERROR
26 // FILETYPEERROR: Unsupported file type
27 //
28 // Test to see if device library related errors are emitted.
29 // RUN: not clang-sycl-linker --dry-run -triple=spirv64 %t_1.bc %t_2.bc --library-path=%t.dir --device-libs= -o a.spv 2>&1 \
30 // RUN: | FileCheck %s --check-prefix=DEVLIBSERR1
31 // DEVLIBSERR1: Number of device library files cannot be zero
32 // RUN: not clang-sycl-linker --dry-run -triple=spirv64 %t_1.bc %t_2.bc --library-path=%t.dir --device-libs=lib1.bc,lib2.bc,lib3.bc -o a.spv 2>&1 \
33 // RUN: | FileCheck %s --check-prefix=DEVLIBSERR2
34 // DEVLIBSERR2: '{{.*}}lib3.bc' SYCL device library file is not found
35 //
36 // Test AOT compilation for an Intel GPU.
37 // RUN: clang-sycl-linker --dry-run -v -triple=spirv64 -arch=bmg_g21 %t_1.bc %t_2.bc -o a.out 2>&1 \
38 // RUN: --ocloc-options="-a -b" \
39 // RUN: | FileCheck %s --check-prefix=AOT-INTEL-GPU
40 // AOT-INTEL-GPU: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc
41 // AOT-INTEL-GPU-NEXT: SPIR-V Backend: input: [[LLVMLINKOUT]].bc, output: [[SPIRVTRANSLATIONOUT:.*]]_0.spv
42 // AOT-INTEL-GPU-NEXT: "{{.*}}ocloc{{.*}}" {{.*}}-device bmg_g21 -a -b {{.*}}-output a_0.out -file [[SPIRVTRANSLATIONOUT]]_0.spv
43 //
44 // Test AOT compilation for an Intel CPU.
45 // RUN: clang-sycl-linker --dry-run -v -triple=spirv64 -arch=graniterapids %t_1.bc %t_2.bc -o a.out 2>&1 \
46 // RUN: --opencl-aot-options="-a -b" \
47 // RUN: | FileCheck %s --check-prefix=AOT-INTEL-CPU
48 // AOT-INTEL-CPU: sycl-device-link: inputs: {{.*}}.bc, {{.*}}.bc libfiles: output: [[LLVMLINKOUT:.*]].bc
49 // AOT-INTEL-CPU-NEXT: SPIR-V Backend: input: [[LLVMLINKOUT]].bc, output: [[SPIRVTRANSLATIONOUT:.*]]_0.spv
50 // AOT-INTEL-CPU-NEXT: "{{.*}}opencl-aot{{.*}}" {{.*}}--device=cpu -a -b {{.*}}-o a_0.out [[SPIRVTRANSLATIONOUT]]_0.spv
51 //
52 // Check that the output file must be specified.
53 // RUN: not clang-sycl-linker --dry-run %t_1.bc %t_2.bc 2>& 1 \
54 // RUN: | FileCheck %s --check-prefix=NOOUTPUT
55 // NOOUTPUT: Output file must be specified
56 //
57 // Check that the target triple must be.
58 // RUN: not clang-sycl-linker --dry-run %t_1.bc %t_2.bc -o a.out 2>& 1 \
59 // RUN: | FileCheck %s --check-prefix=NOTARGET
60 // NOTARGET: Target triple must be specified