diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp index fa72c2cc8838d..82b4dbd459723 100644 --- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp +++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp @@ -723,14 +723,20 @@ runSYCLPostLinkTool(ArrayRef InputFiles, const ArgList &Args) { return SYCLPostLinkPath.takeError(); // Create a new file to write the output of sycl-post-link to. + const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ)); auto TempFileOrErr = createOutputFile(sys::path::filename(ExecutableName), "table"); if (!TempFileOrErr) return TempFileOrErr.takeError(); + std::string OutputPathWithArch = TempFileOrErr->str(); + StringRef Arch = Args.getLastArgValue(OPT_arch_EQ); + if (Triple.getSubArch() == llvm::Triple::SPIRSubArch_gen && Arch.data()) + OutputPathWithArch = "intel_gpu_" + Arch.str() + "," + OutputPathWithArch; + else if (Triple.getSubArch() == llvm::Triple::SPIRSubArch_x86_64) + OutputPathWithArch = "spir64_x86_64," + OutputPathWithArch; SmallVector CmdArgs; CmdArgs.push_back(*SYCLPostLinkPath); - const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ)); Arg *SYCLDeviceLibLoc = Args.getLastArg(OPT_sycl_device_library_location_EQ); if (SYCLDeviceLibLoc && !Triple.isSPIRAOT()) { std::string SYCLDeviceLibLocParam = SYCLDeviceLibLoc->getValue(); @@ -748,7 +754,7 @@ runSYCLPostLinkTool(ArrayRef InputFiles, const ArgList &Args) { SYCLPostLinkOptions.split(CmdArgs, " ", /* MaxSplit = */ -1, /* KeepEmpty = */ false); CmdArgs.push_back("-o"); - CmdArgs.push_back(*TempFileOrErr); + CmdArgs.push_back(Args.MakeArgString(OutputPathWithArch)); for (auto &File : InputFiles) CmdArgs.push_back(File); if (Error Err = executeCommands(*SYCLPostLinkPath, CmdArgs)) @@ -945,24 +951,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..0e5ec09d48af6 100644 --- a/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-1.cpp +++ b/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-1.cpp @@ -20,6 +20,9 @@ // 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: %{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 -g %O0 %s -o %t.out +// RUN: %{run} %t.out + // Tests that aspect::fp64 is not emitted correctly when -fsycl-fp64-conv-emu // flag is used. diff --git a/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp b/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp index 2df3aadb403cd..33ade49960d2b 100644 --- a/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp +++ b/sycl/test-e2e/OptionalKernelFeatures/fp64-conv-emu-2.cpp @@ -23,6 +23,9 @@ // 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: %{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 -g %O0 %s -o %t.out +// RUN: %{run} %t.out + #include using namespace sycl; @@ -61,8 +64,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);