Skip to content

Commit

Permalink
[Driver][SYCL] Assertion when using -P -fsycl on Windows (#2407)
Browse files Browse the repository at this point in the history
When performing preprocessing with -P on Windows, there was an
assumption that we would always be at the top level.  This is not
true when performing offloading.  Make adjustments to allow for
-P to be used with offload.

Signed-off-by: Michael D Toguchi <michael.d.toguchi@intel.com>
  • Loading branch information
mdtoguchi authored Sep 3, 2020
1 parent 78a86da commit a21d7ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 3 additions & 2 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6118,8 +6118,9 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
}

// For /P, preprocess to file named after BaseInput.
if (C.getArgs().hasArg(options::OPT__SLASH_P)) {
assert(AtTopLevel && isa<PreprocessJobAction>(JA));
if (C.getArgs().hasArg(options::OPT__SLASH_P) &&
((AtTopLevel && isa<PreprocessJobAction>(JA)) ||
isa<OffloadBundlingJobAction>(JA))) {
StringRef BaseName = llvm::sys::path::filename(BaseInput);
StringRef NameArg;
if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi))
Expand Down
6 changes: 6 additions & 0 deletions clang/test/Driver/sycl-offload-win.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,11 @@
// FOFFLOAD_STATIC_LIB_SRC2: llvm-link{{(.exe)?}}{{.*}} "@{{.*}}"
// FOFFLOAD_STATIC_LIB_SRC2: link{{(.exe)?}}{{.+}} "-defaultlib:[[LIB]]"

// Check for /P behaviors
// RUN: %clang_cl --target=x86_64-pc-windows-msvc -fsycl -P %s -### 2>&1 | FileCheck -check-prefix=FSYCL_P %s
// FSYCL_P: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown-sycldevice" {{.*}} "-E" {{.*}} "-o" "[[DEVICEPP:.+\.i]]"
// FSYCL_P: clang{{.*}} "-cc1" "-triple" "x86_64-pc-windows-msvc{{.*}}" {{.*}} "-E" {{.*}} "-o" "[[HOSTPP:.+\.i]]"
// FSYCL_P: clang-offload-bundler{{.*}} "-type=i" "-targets=sycl-spir64-unknown-unknown-sycldevice,host-x86_64-pc-windows-msvc" {{.*}} "-inputs=[[DEVICEPP]],[[HOSTPP]]"

// TODO: SYCL specific fail - analyze and enable
// XFAIL: windows-msvc

0 comments on commit a21d7ef

Please sign in to comment.