Skip to content

Commit bc3a43e

Browse files
authored
Partially revert "[Driver][SYCL] Use existing option for device-only … (#15328)
…and some cleanup (#15274)" This partially reverts commit fd4b409, undoing the change to alias -fsycl-device-only and --offload-device-only but keeping the other cleanups, and adds a test showing why the alias does not work. Fixes #15319
1 parent fb94e86 commit bc3a43e

File tree

3 files changed

+11
-21
lines changed

3 files changed

+11
-21
lines changed

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6813,7 +6813,7 @@ def fintelfpga : Flag<["-"], "fintelfpga">,
68136813
MarshallingInfoFlag<LangOpts<"IntelFPGA">>,
68146814
HelpText<"Perform ahead-of-time compilation for FPGA">;
68156815
def fsycl_device_only : Flag<["-"], "fsycl-device-only">,
6816-
Alias<offload_device_only>, HelpText<"Compile SYCL kernels for device">;
6816+
HelpText<"Compile SYCL kernels for device">;
68176817
def fsycl_embed_ir : Flag<["-"], "fsycl-embed-ir">,
68186818
HelpText<"Embed LLVM IR for runtime kernel fusion">;
68196819
defm sycl_esimd_force_stateless_mem : BoolFOption<"sycl-esimd-force-stateless-mem",

clang/lib/Driver/Driver.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -854,19 +854,6 @@ static bool addSYCLDefaultTriple(Compilation &C,
854854
return true;
855855
}
856856

857-
// Special function that checks if -fsycl-device-only was passed on the
858-
// command line. -fsycl-device-only is an alias of --offload-device-only.
859-
static bool hasSYCLDeviceOnly(const ArgList &Args) {
860-
if (const Arg *SYCLDeviceOnlyArg =
861-
Args.getLastArg(options::OPT_offload_device_only)) {
862-
while (SYCLDeviceOnlyArg->getAlias())
863-
SYCLDeviceOnlyArg = SYCLDeviceOnlyArg->getAlias();
864-
if (SYCLDeviceOnlyArg->getSpelling().contains("sycl-device-only"))
865-
return true;
866-
}
867-
return false;
868-
}
869-
870857
void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
871858
InputList &Inputs) {
872859

@@ -1089,7 +1076,7 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C,
10891076
bool HasValidSYCLRuntime =
10901077
C.getInputArgs().hasFlag(options::OPT_fsycl, options::OPT_fno_sycl,
10911078
false) ||
1092-
hasSYCLDeviceOnly(C.getInputArgs());
1079+
C.getInputArgs().hasArg(options::OPT_fsycl_device_only);
10931080

10941081
Arg *SYCLfpga = C.getInputArgs().getLastArg(options::OPT_fintelfpga);
10951082

@@ -1758,12 +1745,13 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
17581745
if (Args.getLastArg(options::OPT_fsycl_dump_device_code_EQ))
17591746
DumpDeviceCode = true;
17601747

1761-
if (const Arg *A = Args.getLastArg(options::OPT_offload_host_only,
1762-
options::OPT_offload_device_only,
1763-
options::OPT_offload_host_device)) {
1748+
if (const Arg *A = Args.getLastArg(
1749+
options::OPT_offload_host_only, options::OPT_offload_device_only,
1750+
options::OPT_fsycl_device_only, options::OPT_offload_host_device)) {
17641751
if (A->getOption().matches(options::OPT_offload_host_only))
17651752
Offload = OffloadHost;
1766-
else if (A->getOption().matches(options::OPT_offload_device_only))
1753+
else if (A->getOption().matches(options::OPT_offload_device_only) ||
1754+
A->getOption().matches(options::OPT_fsycl_device_only))
17671755
Offload = OffloadDevice;
17681756
else
17691757
Offload = OffloadHostDevice;
@@ -3138,7 +3126,7 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
31383126
Arg *InputTypeArg = nullptr;
31393127
bool IsSYCL =
31403128
Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false) ||
3141-
hasSYCLDeviceOnly(Args);
3129+
Args.hasArg(options::OPT_fsycl_device_only);
31423130

31433131
// The last /TC or /TP option sets the input type to C or C++ globally.
31443132
if (Arg *TCTP = Args.getLastArgNoClaim(options::OPT__SLASH_TC,

clang/test/Driver/sycl-device.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
// RUN: | FileCheck -check-prefix=CHECK-DEFAULT %s
44
// CHECK-DEFAULT-NOT: "-fsycl-is-device"
55

6-
/// Check "-fsycl-is-device" is passed when compiling for device:
6+
/// Check "-fsycl-is-device" is passed when compiling for device, including when --config is used:
77
// RUN: %clang -### -fsycl-device-only %s 2>&1 \
88
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
9+
// RUN: %clang -### --config=%S/Inputs/empty.cfg -fsycl-device-only %s 2>&1 \
10+
// RUN: | FileCheck -check-prefix=CHECK-SYCL-DEV %s
911
// CHECK-SYCL-DEV: "-fsycl-is-device"{{.*}} "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include{{[/\\]+}}sycl" "-internal-isystem" "{{.*}}bin{{[/\\]+}}..{{[/\\]+}}include"
1012

1113
/// Check that "-Wno-sycl-strict" is set on compiler invocation with "-fsycl"

0 commit comments

Comments
 (0)