Skip to content

Commit

Permalink
[SYCL] -fsycl-device-only should override -fsycl
Browse files Browse the repository at this point in the history
Use of -fsycl-device-only should only produce device code even in the presence
of -fsycl.  The default mode of 'dpcpp' is -fsycl so the override is
necessary for -fsycl-device-only to work

Signed-off-by: Michael D Toguchi <michael.d.toguchi@intel.com>
  • Loading branch information
mdtoguchi authored and bader committed Sep 6, 2019
1 parent b4a0e50 commit d429243
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,9 +718,11 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
//
// We need to generate a SYCL toolchain if the user specified targets with
// the -fsycl-targets, -fsycl-add-targets or -fsycl-link-targets option.
// If -fsycl is supplied without any of these we will assume SPIR-V
bool HasValidSYCLRuntime = C.getInputArgs().hasFlag(options::OPT_fsycl,
options::OPT_fno_sycl, false);
// If -fsycl is supplied without any of these we will assume SPIR-V.
// Use of -fsycl-device-only overrides -fsycl.
bool HasValidSYCLRuntime = (C.getInputArgs().hasFlag(options::OPT_fsycl,
options::OPT_fno_sycl, false) &&
!C.getInputArgs().hasArg(options::OPT_sycl_device_only));

Arg *SYCLTargets =
C.getInputArgs().getLastArg(options::OPT_fsycl_targets_EQ);
Expand Down
1 change: 1 addition & 0 deletions clang/test/Driver/sycl.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// RUN: %clang -### --sycl -c %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
// RUN: %clang -### --sycl %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
// RUN: %clang -### -fsycl-device-only -fsycl %s 2>&1 | FileCheck %s --check-prefix=DEFAULT
// RUN: %clang -### --sycl -fno-sycl-use-bitcode -c %s 2>&1 | FileCheck %s --check-prefix=NO-BITCODE
// RUN: %clang -### -target spir64-unknown-linux-sycldevice -c -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=TARGET
// RUN: %clang -### --sycl -c -emit-llvm %s 2>&1 | FileCheck %s --check-prefix=COMBINED
Expand Down

0 comments on commit d429243

Please sign in to comment.