Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions clang/include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,13 @@ class Driver {
/// specified subarch
llvm::Triple MakeSYCLDeviceTriple(StringRef TargetArch = "spir64") const;

/// Utility function to parse all devices passed via -fsycl-targets.
/// Return 'true' for JIT, AOT Intel CPU/GPUs and NVidia/AMD targets.
/// Otherwise return 'false'.
bool
GetUseNewOffloadDriverForSYCLOffload(Compilation &C,
const llvm::opt::ArgList &Args) const;

/// PrintActions - Print the list of actions.
void PrintActions(const Compilation &C) const;

Expand Down
36 changes: 31 additions & 5 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,32 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt,
Args.append(Copy);
}

/// Utility function to parse all devices passed via -fsycl-targets.
/// Return 'true' for JIT, AOT Intel CPU/GPUs and NVidia/AMD targets.
/// Otherwise return 'false'.
bool Driver::GetUseNewOffloadDriverForSYCLOffload(Compilation &C,
Copy link
Contributor

@YixingZhang007 YixingZhang007 Oct 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a comment from Marcos "I think the name doesn't describe very well what the function is doing, or at least doesn't align very well with the description in the comment above. I would expect something including the words Get and Devices at least." More details can be found at #20470.

const ArgList &Args) const {
// Check only if enabled with -fsycl
if (!Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl, false))
return false;

if (Args.hasFlag(options::OPT_no_offload_new_driver,
options::OPT_offload_new_driver, false))
return false;

if (Args.hasArg(options::OPT_fintelfpga))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is a comment from Srividya Sundaram "support for FPGA related options have been removed in this #16864 Don't think this check is necessary." More details can be found at #20470.

return false;

if (const Arg *A = Args.getLastArg(options::OPT_fsycl_targets_EQ)) {
for (const char *Val : A->getValues()) {
llvm::Triple TT(C.getDriver().MakeSYCLDeviceTriple(Val));
if ((!TT.isSPIROrSPIRV()) || TT.isSPIRAOT())
return false;
}
}
return true;
}

bool Driver::readConfigFile(StringRef FileName,
llvm::cl::ExpansionContext &ExpCtx) {
// Try opening the given file.
Expand Down Expand Up @@ -1899,11 +1925,10 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
// Use new offloading path for OpenMP. This is disabled as the SYCL
// offloading path is not properly setup to use the updated device linking
// scheme.
if ((C->isOffloadingHostKind(Action::OFK_OpenMP) &&
TranslatedArgs->hasFlag(options::OPT_fopenmp_new_driver,
options::OPT_no_offload_new_driver, true)) ||
if (C->isOffloadingHostKind(Action::OFK_OpenMP) ||
TranslatedArgs->hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver, false))
options::OPT_no_offload_new_driver, false) ||
GetUseNewOffloadDriverForSYCLOffload(*C, *TranslatedArgs))
setUseNewOffloadingDriver();

// Determine FPGA emulation status.
Expand Down Expand Up @@ -7289,7 +7314,8 @@ void Driver::BuildActions(Compilation &C, DerivedArgList &Args,
bool UseNewOffloadingDriver =
C.isOffloadingHostKind(Action::OFK_OpenMP) ||
Args.hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver, false);
options::OPT_no_offload_new_driver, false) ||
GetUseNewOffloadDriverForSYCLOffload(C, Args);

// Builder to be used to build offloading actions.
std::unique_ptr<OffloadingActionBuilder> OffloadBuilder =
Expand Down
10 changes: 6 additions & 4 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5229,10 +5229,12 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
bool IsDeviceOffloadAction = !(JA.isDeviceOffloading(Action::OFK_None) ||
JA.isDeviceOffloading(Action::OFK_Host));
bool IsHostOffloadingAction =
JA.isHostOffloading(Action::OFK_OpenMP) ||
(JA.isHostOffloading(C.getActiveOffloadKinds()) &&
Args.hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver, false));
(JA.isHostOffloading(Action::OFK_OpenMP) ||
(JA.isHostOffloading(C.getActiveOffloadKinds()) &&
Args.hasFlag(options::OPT_offload_new_driver,
options::OPT_no_offload_new_driver, false))) ||
(JA.isHostOffloading(Action::OFK_SYCL) &&
C.getDriver().GetUseNewOffloadDriverForSYCLOffload(C, Args));

bool IsRDCMode =
Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc, IsSYCL);
Expand Down