Skip to content

Commit 1edd217

Browse files
mdtoguchiromanovvlad
authored andcommitted
[SYCL][Driver] Prevent option duplication during offload
Under certain circumstances, the offload compilation would pull in duplicate arguments to the offload compilation steps. This was being caused by some hosts having their own translation step, adding the args to the derived arg list before the offload translation which adds the args as well. Signed-off-by: Michael D Toguchi <[email protected]>
1 parent 81f5dff commit 1edd217

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

clang/lib/Driver/ToolChains/SYCL.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -416,15 +416,14 @@ SYCLToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
416416
Action::OffloadKind DeviceOffloadKind) const {
417417
DerivedArgList *DAL =
418418
HostTC.TranslateArgs(Args, BoundArch, DeviceOffloadKind);
419-
if (!DAL)
420-
DAL = new DerivedArgList(Args.getBaseArgs());
421-
422-
const OptTable &Opts = getDriver().getOpts();
423419

424-
for (Arg *A : Args) {
425-
DAL->append(A);
420+
if (!DAL) {
421+
DAL = new DerivedArgList(Args.getBaseArgs());
422+
for (Arg *A : Args)
423+
DAL->append(A);
426424
}
427425

426+
const OptTable &Opts = getDriver().getOpts();
428427
if (!BoundArch.empty()) {
429428
DAL->eraseArg(options::OPT_march_EQ);
430429
DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ),

clang/test/Driver/sycl-offload.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,5 +761,10 @@
761761
// RUN: | FileCheck -check-prefix=LIB-UNBUNDLE-CHECK %s
762762
// LIB-UNBUNDLE-CHECK-NOT: clang-offload-unbundler
763763

764+
/// Options should not be duplicated in AOT calls
765+
// RUN: %clang -fsycl -### -fsycl-targets=spir64_fpga -Xsycl-target-backend "-DBLAH" %s 2>&1 \
766+
// RUN: | FileCheck -check-prefix=DUP-OPT %s
767+
// DUP-OPT-NOT: aoc{{.*}} "-DBLAH" {{.*}} "-DBLAH"
768+
764769
// TODO: SYCL specific fail - analyze and enable
765770
// XFAIL: windows-msvc

0 commit comments

Comments
 (0)