From 5794326b965071a69273a1f653405670b728e66b Mon Sep 17 00:00:00 2001 From: Pietro Ghiglio Date: Tue, 14 May 2024 14:32:21 +0200 Subject: [PATCH] [SYCL][NATIVECPU][DRIVER] Select remangled libclc variant for Native CPU (#13765) This PR makes it so we build the remangled variants for Native CPU libclc, and ensures that the driver selects it. --- buildbot/configure.py | 5 +++-- clang/lib/Driver/Driver.cpp | 9 +++++++-- .../native_cpu/sycl-native-cpu-libclc.cpp | 7 ++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/buildbot/configure.py b/buildbot/configure.py index 7a801afcde47..720ebb156eae 100644 --- a/buildbot/configure.py +++ b/buildbot/configure.py @@ -88,8 +88,9 @@ def do_configure(args): sycl_enabled_plugins.append("hip") if args.native_cpu: - #Todo: we should set whatever targets we support for native cpu - libclc_targets_to_build += ';x86_64-unknown-linux-gnu' + # Todo: we should set whatever targets we support for native cpu + libclc_targets_to_build += ";x86_64-unknown-linux-gnu" + libclc_gen_remangled_variants = "ON" sycl_enabled_plugins.append("native_cpu") diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 523c5786999d..2a7ab492b54d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -5856,8 +5856,13 @@ class OffloadingActionBuilder final { llvm::sys::path::append(WithInstallPath, Twine("../../../share/clc")); LibraryPaths.emplace_back(WithInstallPath.c_str()); - // Select libclc variant based on target triple - std::string LibSpirvTargetName = "libspirv-"; + // Select libclc variant based on target triple. + // On Windows long is 32 bits, so we have to select the right remangled + // libclc version. + std::string LibSpirvTargetName = + (TC->getAuxTriple()->isOSWindows()) + ? "remangled-l32-signed_char.libspirv-" + : "remangled-l64-signed_char.libspirv-"; LibSpirvTargetName.append(TC->getTripleString() + ".bc"); for (StringRef LibraryPath : LibraryPaths) { diff --git a/sycl/test/check_device_code/native_cpu/sycl-native-cpu-libclc.cpp b/sycl/test/check_device_code/native_cpu/sycl-native-cpu-libclc.cpp index 4fded32735e6..afebe7b67778 100644 --- a/sycl/test/check_device_code/native_cpu/sycl-native-cpu-libclc.cpp +++ b/sycl/test/check_device_code/native_cpu/sycl-native-cpu-libclc.cpp @@ -2,4 +2,9 @@ // REQUIRES: native_cpu // RUN: %clang -### -fsycl -fsycl-targets=native_cpu -target x86_64-unknown-linux-gnu %s 2> %t.ncpu.out // RUN: FileCheck %s --input-file %t.ncpu.out -// CHECK: libspirv-x86_64-unknown-linux-gnu.bc +// CHECK: {{(\\|/)}}remangled-l64-signed_char.libspirv-x86_64-unknown-linux-gnu.bc" + +// Check that l32 variant is selected for Windows +// RUN: %clang -### -fsycl -fsycl-targets=native_cpu -target x86_64-windows %s 2> %t-win.ncpu.out +// RUN: FileCheck %s --input-file %t-win.ncpu.out --check-prefix=CHECK-WIN +// CHECK-WIN: {{(\\|/)}}remangled-l32-signed_char.libspirv-x86_64-unknown-windows-msvc.bc"