Skip to content

Commit a21d7ef

Browse files
authored
[Driver][SYCL] Assertion when using -P -fsycl on Windows (#2407)
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 <[email protected]>
1 parent 78a86da commit a21d7ef

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

clang/lib/Driver/Driver.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6118,8 +6118,9 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
61186118
}
61196119

61206120
// For /P, preprocess to file named after BaseInput.
6121-
if (C.getArgs().hasArg(options::OPT__SLASH_P)) {
6122-
assert(AtTopLevel && isa<PreprocessJobAction>(JA));
6121+
if (C.getArgs().hasArg(options::OPT__SLASH_P) &&
6122+
((AtTopLevel && isa<PreprocessJobAction>(JA)) ||
6123+
isa<OffloadBundlingJobAction>(JA))) {
61236124
StringRef BaseName = llvm::sys::path::filename(BaseInput);
61246125
StringRef NameArg;
61256126
if (Arg *A = C.getArgs().getLastArg(options::OPT__SLASH_Fi))

clang/test/Driver/sycl-offload-win.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,5 +95,11 @@
9595
// FOFFLOAD_STATIC_LIB_SRC2: llvm-link{{(.exe)?}}{{.*}} "@{{.*}}"
9696
// FOFFLOAD_STATIC_LIB_SRC2: link{{(.exe)?}}{{.+}} "-defaultlib:[[LIB]]"
9797

98+
// Check for /P behaviors
99+
// RUN: %clang_cl --target=x86_64-pc-windows-msvc -fsycl -P %s -### 2>&1 | FileCheck -check-prefix=FSYCL_P %s
100+
// FSYCL_P: clang{{.*}} "-cc1" "-triple" "spir64-unknown-unknown-sycldevice" {{.*}} "-E" {{.*}} "-o" "[[DEVICEPP:.+\.i]]"
101+
// FSYCL_P: clang{{.*}} "-cc1" "-triple" "x86_64-pc-windows-msvc{{.*}}" {{.*}} "-E" {{.*}} "-o" "[[HOSTPP:.+\.i]]"
102+
// FSYCL_P: clang-offload-bundler{{.*}} "-type=i" "-targets=sycl-spir64-unknown-unknown-sycldevice,host-x86_64-pc-windows-msvc" {{.*}} "-inputs=[[DEVICEPP]],[[HOSTPP]]"
103+
98104
// TODO: SYCL specific fail - analyze and enable
99105
// XFAIL: windows-msvc

0 commit comments

Comments
 (0)