Skip to content

Commit 25bbe42

Browse files
mdtoguchibader
authored andcommitted
[SYCL][Driver] Device link job should not be added for non-existent inputs (#836)
When compiling with only libraries (no source) there should be no device linking step added. We were already preventing the library from being added to the link list, but we were still adding the device link. Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 0d2dab4 commit 25bbe42

File tree

3 files changed

+20
-11
lines changed

3 files changed

+20
-11
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3414,6 +3414,9 @@ class OffloadingActionBuilder final {
34143414
++TC;
34153415
continue;
34163416
}
3417+
if (LI.empty())
3418+
// Current list is empty, nothing to process.
3419+
continue;
34173420

34183421
// Perform a check for device kernels. This is done for FPGA when an
34193422
// aocx or aocr based file is found.

clang/test/Driver/sycl-offload-intelfpga.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,23 +88,22 @@
8888
// RUN: llc -filetype=obj -o %t-aocx.o %t-aocx.bc
8989
// RUN: llvm-ar crv %t_aocx.a %t.o %t-aocx.o
9090
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %t_aocx.a -ccc-print-phases 2>&1 \
91-
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES,CHK-FPGA-AOCX-PHASES-DEFAULT %s
91+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES %s
9292
// RUN: %clang_cl -fsycl -fintelfpga %t_aocx.a -ccc-print-phases 2>&1 \
93-
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES,CHK-FPGA-AOCX-PHASES-CL %s
93+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX-PHASES %s
9494
// CHK-FPGA-AOCX-PHASES: 0: input, "{{.*}}", object, (host-sycl)
9595
// CHK-FPGA-AOCX-PHASES: 1: linker, {0}, image, (host-sycl)
96-
// CHK-FPGA-AOCX-PHASES: 2: linker, {}, spirv, (device-sycl)
97-
// CHK-FPGA-AOCX-PHASES: 3: backend-compiler, {2}, fpga-aocx, (device-sycl)
98-
// CHK-FPGA-AOCX-PHASES: 4: clang-offload-wrapper, {3}, object, (device-sycl)
99-
// CHK-FPGA-AOCX-PHASES-DEFAULT: 5: offload, "host-sycl (x86_64-unknown-linux-gnu)" {1}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice)" {4}, image
100-
// CHK-FPGA-AOCX-PHASES-CL: 5: offload, "host-sycl (x86_64-pc-windows-msvc)" {1}, "device-sycl (spir64_fpga-unknown-unknown-sycldevice-coff)" {4}, image
10196

10297
// RUN: %clangxx -target x86_64-unknown-linux-gnu -fsycl -fintelfpga %t_aocx.a -### 2>&1 \
103-
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX %s
98+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX,CHK-FPGA-AOCX-LIN %s
99+
// RUN: %clang_cl -fsycl -fintelfpga %t_aocx.a -### 2>&1 \
100+
// RUN: | FileCheck -check-prefixes=CHK-FPGA-AOCX,CHK-FPGA-AOCX-WIN %s
104101
// CHK-FPGA-AOCX: clang-offload-bundler{{.*}} "-type=ao" "-targets=sycl-fpga_aocx-intel-unknown-sycldevice" "-inputs=[[LIBINPUT:.+\.a]]" "-outputs=[[BUNDLEOUT:.+\.aocx]]" "-unbundle"
105-
// CHK-FPGA-AOCX: clang-offload-wrapper{{.*}} "-o=[[WRAPOUT:.+\.bc]]" "-host=x86_64-unknown-linux-gnu" "-target=spir64_fpga" "-kind=sycl" "[[BUNDLEOUT]]"
106-
// CHK-FPGA-AOCX: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT:.+\.o]]" "[[WRAPOUT]]"
107-
// CHK-FPGA-AOCX: ld{{.*}} "[[LIBINPUT]]" "[[LLCOUT]]"
102+
// CHK-FPGA-AOCX: clang-offload-wrapper{{.*}} "-o=[[WRAPOUT:.+\.bc]]" {{.*}} "-target=spir64_fpga" "-kind=sycl" "[[BUNDLEOUT]]"
103+
// CHK-FPGA-AOCX-LIN: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT:.+\.o]]" "[[WRAPOUT]]"
104+
// CHK-FPGA-AOCX-WIN: llc{{.*}} "-filetype=obj" "-o" "[[LLCOUT2:.+\.obj]]" "[[WRAPOUT]]"
105+
// CHK-FPGA-AOCX-LIN: ld{{.*}} "[[LIBINPUT]]" "[[LLCOUT]]"
106+
// CHK-FPGA-AOCX-WIN: link{{.*}} "[[LIBINPUT]]" "[[LLCOUT2]]"
108107

109108
/// -fintelfpga -fsycl-link from source
110109
// RUN: touch %t.cpp

clang/test/Driver/sycl-offload.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,5 +793,12 @@
793793
// RUN: | FileCheck -check-prefix=DUP-OPT %s
794794
// DUP-OPT-NOT: aoc{{.*}} "-DBLAH" {{.*}} "-DBLAH"
795795

796+
/// passing of only a library should not create a device link
797+
// RUN: %clang -ccc-print-phases -fsycl -lsomelib 2>&1 \
798+
// RUN: | FileCheck -check-prefix=LIB-NODEVICE %s
799+
// LIB-NODEVICE: 0: input, "somelib", object, (host-sycl)
800+
// LIB-NODEVICE: 1: linker, {0}, image, (host-sycl)
801+
// LIB-NODEVICE-NOT: linker, {{.*}}, spirv, (device-sycl)
802+
796803
// TODO: SYCL specific fail - analyze and enable
797804
// XFAIL: windows-msvc

0 commit comments

Comments
 (0)