diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 6adfe28a57106..9c84865905922 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -9484,9 +9484,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA, StringRef OffloadingPrefix) const { std::string BoundArch = OrigBoundArch.str(); if (is_style_windows(llvm::sys::path::Style::native)) { - // BoundArch may contains ':', which is invalid in file names on Windows, - // therefore replace it with '%'. + // BoundArch may contain ':' or '*', which is invalid in file names on + // Windows, therefore replace it with '@'. std::replace(BoundArch.begin(), BoundArch.end(), ':', '@'); + std::replace(BoundArch.begin(), BoundArch.end(), '*', '@'); } llvm::PrettyStackTraceString CrashInfo("Computing output path"); diff --git a/clang/test/Driver/sycl-windows-device-filename.cpp b/clang/test/Driver/sycl-windows-device-filename.cpp new file mode 100644 index 0000000000000..d179853c94fba --- /dev/null +++ b/clang/test/Driver/sycl-windows-device-filename.cpp @@ -0,0 +1,20 @@ +// Test valid file names from -device values for GPU +// REQUIRES: system-windows + +// RUN: %clang -### --target=x86_64-pc-windows-msvc -fsycl \ +// RUN: -fsycl-targets=spir64_gen --offload-new-driver \ +// RUN: -Xsycl-target-backend "-device arch1:arch2" %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK_COLON + +// CHECK_COLON: sycl-windows-device-filename-arch1@arch2 +// CHECK_COLON: arch=arch1:arch2 +// CHECK_COLON-NOT: sycl-windows-device-filename-arch1:arch2 + +// RUN: %clang -### --target=x86_64-pc-windows-msvc -fsycl \ +// RUN: -fsycl-targets=spir64_gen --offload-new-driver \ +// RUN: -Xsycl-target-backend "-device *" %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix=CHECK_STAR + +// CHECK_STAR: sycl-windows-device-filename-@ +// CHECK_STAR: arch=* +// CHECK_STAR-NOT: sycl-windows-device-filename-*