diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index 0b49c83f35d15..7fbd280ce51dc 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -945,24 +945,29 @@ static void addBackendOptions(const ArgList &Args, if (IsCPU) { OptC.split(CmdArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false); } else { - // ocloc -options args need to be comma separated, e.g. `-options - // "-g,-cl-opt-disable"`. Otherwise, only the first arg is processed by - // ocloc as an arg for -options, and the rest are processed as standalone - // flags, possibly leading to errors. + // ocloc -options takes arguments in the form of '-options "-g + // -cl-opt-disable"' where each argument is separated with spaces. // split function here returns a pair with everything before the separator // ("-options") in the first member of the pair, and everything after the // separator in the second part of the pair. The separator is not included // in any of them. auto [BeforeOptions, AfterOptions] = OptC.split("-options "); // Only add if not empty, an empty arg can lead to ocloc errors. - if (!BeforeOptions.empty()) - CmdArgs.push_back(BeforeOptions); + if (!BeforeOptions.empty()) { + SmallVector BeforeArgs; + BeforeOptions.split(BeforeArgs, " ", /*MaxSplit=*/-1, + /*KeepEmpty=*/false); + for (const auto &string : BeforeArgs) { + CmdArgs.push_back(string); + } + } if (!AfterOptions.empty()) { - // Separator not included by the split function, so explicitly added here. CmdArgs.push_back("-options"); - std::string Replace = AfterOptions.str(); - std::replace(Replace.begin(), Replace.end(), ' ', ','); - CmdArgs.push_back(Args.MakeArgString(Replace)); + // Split the options string by spaces and rejoin to normalize whitespace + SmallVector AfterArgs; + AfterOptions.split(AfterArgs, " ", /*MaxSplit=*/-1, /*KeepEmpty=*/false); + std::string JoinedOptions = llvm::join(AfterArgs, " "); + CmdArgs.push_back(Args.MakeArgString(JoinedOptions)); } } StringRef OptL = diff --git a/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-1.cpp b/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-1.cpp index 9cd673f7161b0..270f08ee91639 100644 --- a/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-1.cpp +++ b/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-1.cpp @@ -17,7 +17,13 @@ // UNSUPPORTED: cuda, hip // UNSUPPORTED-INTENDED: FP64 emulation is an Intel specific feature. -// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu %O0 %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --no-offload-new-driver %O0 %s -o %t.out +// RUN: %{run} %t.out + +// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --offload-new-driver %O0 %s -o %t.out +// RUN: %{run} %t.out + +// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --offload-new-driver -g %O0 %s -o %t.out // RUN: %{run} %t.out // Tests that aspect::fp64 is not emitted correctly when -fsycl-fp64-conv-emu diff --git a/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp b/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp index 2df3aadb403cd..cfcce34a7f6a1 100644 --- a/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp +++ b/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp @@ -20,7 +20,13 @@ // UNSUPPORTED: cuda, hip // UNSUPPORTED-INTENDED: FP64 emulation is an Intel specific feature. -// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu %O0 %s -o %t.out +// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --no-offload-new-driver %O0 %s -o %t.out +// RUN: %{run} %t.out + +// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --offload-new-driver %O0 %s -o %t.out +// RUN: %{run} %t.out + +// RUN: %clangxx -fsycl -fsycl-targets=intel_gpu_dg2_g10,intel_gpu_dg2_g11,intel_gpu_dg2_g12,intel_gpu_pvc,intel_gpu_mtl_h,intel_gpu_mtl_u -fsycl-fp64-conv-emu --offload-new-driver -g %O0 %s -o %t.out // RUN: %{run} %t.out #include @@ -61,8 +67,16 @@ int main() { nfail += test>(q); nfail += test>(q); - if (q.get_device().has(aspect::fp64)) - nfail += test>(q); + // This test is currently disabled because it requires the -ze-fp64-gen-emu + // IGC option to run FP64 arithmetic operations. The -fsycl-fp64-conv-emu flag + // only enables the -ze-fp64-gen-conv-emu IGC option, which provides partial + // FP64 emulation limited to kernels with FP64 conversions but no FP64 + // computations. + // TODO: Implement support for a new flag, -fsycl-fp64-gen-emu, which will + // enable the use of the -ze-fp64-gen-emu IGC option. + // if (q.get_device().has(aspect::fp64)) { + // nfail += test>(q); + // } nfail += test>(q);