Skip to content

Commit bab77c0

Browse files
committed
Add more testing
Signed-off-by: Arvind Sudarsanam <[email protected]>
1 parent e69ddfd commit bab77c0

File tree

3 files changed

+50
-6
lines changed

3 files changed

+50
-6
lines changed
Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,47 @@
1-
// Tests the clang-sycl-linker tool
1+
// Tests the clang-sycl-linker tool.
22
//
3-
// Test a simple case without arguments
3+
// Test a simple case without arguments.
44
// RUN: %clangxx -fsycl -emit-llvm -c %s -o %t.bc
5+
// RUN: clang-sycl-linker --dry-run -triple spirv64 %t.bc -o a.spv 2>&1 \
6+
// RUN: | FileCheck %s --check-prefix=SIMPLE
7+
// SIMPLE: "{{.*}}llvm-link{{.*}}" {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
8+
// SIMPLE-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[FIRSTLLVMLINKOUT]].bc
9+
//
10+
// Test a simple case with device library files specified.
511
// RUN: echo ' ' > %T/lib1.bc
612
// RUN: echo ' ' > %T/lib2.bc
713
// RUN: clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1 \
8-
// RUN: | FileCheck %s --check-prefix=CMDS
9-
// CMDS: "{{.*}}llvm-link{{.*}}" {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
10-
// CMDS-NEXT: "{{.*}}llvm-link{{.*}}" -only-needed [[FIRSTLLVMLINKOUT]].bc {{.*}}lib1.bc {{.*}}lib2.bc -o [[SECONDLLVMLINKOUT:.*]].bc --suppress-warnings
11-
// CMDS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
14+
// RUN: | FileCheck %s --check-prefix=DEVLIBS
15+
// DEVLIBS: "{{.*}}llvm-link{{.*}}" {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
16+
// DEVLIBS-NEXT: "{{.*}}llvm-link{{.*}}" -only-needed [[FIRSTLLVMLINKOUT]].bc {{.*}}lib1.bc {{.*}}lib2.bc -o [[SECONDLLVMLINKOUT:.*]].bc --suppress-warnings
17+
// DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
18+
//
19+
// Test a simple case with .o (fat object) as input.
20+
// TODO: Remove this test once fat object support is added.
21+
// RUN: %clangxx -fsycl -c %s -o %t.o
22+
// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.o -o a.spv 2>&1 \
23+
// RUN: | FileCheck %s --check-prefix=FILETYPEERROR
24+
// FILETYPEERROR: Unsupported file type
25+
//
26+
// Test to see if device library related errors are emitted.
27+
// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs= -o a.spv 2>&1 \
28+
// RUN: | FileCheck %s --check-prefix=DEVLIBSERR1
29+
// DEVLIBSERR1: Number of device library files cannot be zero
30+
// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs=lib3.bc -o a.spv 2>&1 \
31+
// RUN: | FileCheck %s --check-prefix=DEVLIBSERR2
32+
// DEVLIBSERR2: SYCL device library file is not found
33+
//
34+
// Test if correct set of llvm-spirv options are emitted for windows environment.
35+
// RUN: clang-sycl-linker --dry-run -triple spirv64 --is-windows-msvc-env %t.bc -o a.spv 2>&1 \
36+
// RUN: | FileCheck %s --check-prefix=LLVMOPTSWIN
37+
// LLVMOPTSWIN: -spirv-debug-info-version=ocl-100 -spirv-allow-extra-diexpressions -spirv-allow-unknown-intrinsics=llvm.genx. -spirv-ext=
38+
//
39+
// Test if correct set of llvm-spirv options are emitted for linux environment.
40+
// RUN: clang-sycl-linker --dry-run -triple spirv64 %t.bc -o a.spv 2>&1 \
41+
// RUN: | FileCheck %s --check-prefix=LLVMOPTSLIN
42+
// LLVMOPTSLIN: -spirv-debug-info-version=nonsemantic-shader-200 -spirv-allow-unknown-intrinsics=llvm.genx. -spirv-ext=
43+
//
44+
// Test that no llvm-spirv error is emitted as expected.
45+
// RUN: not clang-sycl-linker -triple spirv64 %t.bc -o a.spv 2>&1 \
46+
// RUN: | FileCheck %s --check-prefix=LLVMSPIRVERR
47+
// LLVMSPIRVERR: Unable to find 'llvm-spirv' in path

clang/test/Driver/sycl-link-spirv-target.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@
55
// RUN: %clangxx --target=spirv64 --sycl-link -### %t.bc 2>&1 \
66
// RUN: | FileCheck %s -check-prefix=LINK
77
// LINK: "{{.*}}clang-sycl-linker{{.*}}" "{{.*}}.bc" "-o" "a.out"
8+
//
9+
// Test that -Xlinker options are being passed to clang-sycl-linker.
10+
// RUN: %clangxx -### --target=spirv64 --sycl-link -Xlinker --llvm-spirv-path=/tmp \
11+
// RUN: -Xlinker --library-path=/tmp -Xlinker --device-libs=lib1.bc,lib2.bc %t.bc 2>&1 \
12+
// RUN: | FileCheck %s -check-prefix=XLINKEROPTS
13+
// XLINKEROPTS: "{{.*}}clang-sycl-linker{{.*}}" "--llvm-spirv-path=/tmp" "--library-path=/tmp" "--device-libs=lib1.bc,lib2.bc" "{{.*}}.bc" "-o" "a.out"

clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ Expected<SmallVector<std::string>> getInput(const ArgList &Args) {
188188
file_magic Magic;
189189
if (auto EC = identify_magic(*Filename, Magic))
190190
return createStringError("Failed to open file " + *Filename);
191+
// TODO: Current use case involves LLVM IR bitcode files as input.
192+
// This will be extended to support fat objects and SPIR-V IR files.
191193
if (Magic != file_magic::bitcode)
192194
return createStringError("Unsupported file type");
193195
BitcodeFiles.push_back(*Filename);

0 commit comments

Comments
 (0)