Skip to content

[SYCL] Use compiler-rt builtin library in SYCL for spirv target - #23111

Open
jinge90 wants to merge 8 commits into
intel:syclfrom
jinge90:builtin_for_sycl
Open

[SYCL] Use compiler-rt builtin library in SYCL for spirv target#23111
jinge90 wants to merge 8 commits into
intel:syclfrom
jinge90:builtin_for_sycl

Conversation

@jinge90

@jinge90 jinge90 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Most changes to compiler-rt to make spirv build pass have been submitted to commnuity. This PR aims to build and link compiler-rt builtin library for spirv target and use it in SYCL compiler. We will remove __mulsc3/__muldc3/__divsc3/__divdc3/ in libdevice and use the same functions from compiler-rt builtin library.

Signed-off-by: jinge90 <ge.jin@intel.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
@jinge90
jinge90 requested review from a team, bader and cperkinsintel as code owners September 7, 2026 08:08
@jinge90
jinge90 marked this pull request as draft September 7, 2026 08:08
@jinge90
jinge90 marked this pull request as ready for review September 8, 2026 02:53
@jinge90
jinge90 requested a balanced review from Copilot September 8, 2026 02:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

macOS, custom JIT configurations, and clean parallel builds can fail to produce or locate the required builtins bitcode.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Integrates SPIR-V compiler-rt builtins into SYCL device linking and removes duplicated complex arithmetic implementations.

Changes:

  • Builds, packages, and discovers SPIR-V compiler-rt bitcode.
  • Links builtins through the SYCL driver and JIT compiler.
  • Replaces libdevice complex helpers and updates driver tests.
File summaries
File Description
sycl/CMakeLists.txt Adds SPIR-V builtins to toolchain deployment.
sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp Loads compiler-rt during JIT linking.
sycl-jit/jit-compiler/CMakeLists.txt Embeds SPIR-V builtins in JIT resources.
libdevice/fallback-complex.hpp Uses compiler-generated float complex helpers.
libdevice/fallback-complex-fp64.hpp Uses compiler-generated double complex helpers.
libdevice/complex_wrapper.hpp Removes duplicated builtin wrappers.
libdevice/cmake/modules/SYCLLibdevice.cmake Enables strict complex arithmetic lowering.
compiler-rt/lib/builtins/CMakeLists.txt Adds the SPIR-V address-space flag.
compiler-rt/cmake/builtin-config-ix.cmake Detects support for that flag.
clang/test/Driver/sycl-no-rdc-win.cpp Updates phase indices.
clang/test/Driver/sycl-no-rdc-old-model.cpp Updates phase indices.
clang/test/Driver/sycl-no-rdc-fat-archive-win.cpp Updates phase indices.
clang/test/Driver/sycl-no-rdc-fat-archive-old-model.cpp Updates phase indices.
clang/test/Driver/Inputs/SYCL/lib/clang/resource_dir/lib/spirv64-unknown-unknown/libclang_rt.builtins.bc Adds a driver-test fixture.
clang/lib/Driver/ToolChains/SYCL.cpp Selects and locates SPIR-V builtins.
clang/lib/Driver/Driver.cpp Adds the builtins directory to legacy linking.
buildbot/configure.py Configures the SPIR-V compiler-rt runtime.
Review details
  • Files reviewed: 16/17 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread buildbot/configure.py Outdated
Comment thread sycl-jit/jit-compiler/CMakeLists.txt Outdated
Comment thread sycl/CMakeLists.txt
Comment on lines +671 to +672
"libsycl-imf",
"libclang_rt.builtins"};
jinge90 and others added 3 commits September 8, 2026 11:12
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
Signed-off-by: jinge90 <ge.jin@intel.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Builtins are unavailable in optional-runtime configurations and incompatible with currently selected 32-bit SPIR targets.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (2)

Previously missed (1) — in code that hasn't changed since the last review.

libdevice/fallback-complex.hpp:69

  • This replacement removes the implementation of the documented cl_intel_devicelib_complex entry points __devicelib___mulsc3 and __devicelib___divsc3, but sycl/doc/design/DeviceLibExtensions.rst:193-194 still advertises them. Update the extension contract (and the corresponding fp64 declarations at lines 233-234) so consumers are not promised symbols that libdevice no longer provides.

clang/lib/Driver/ToolChains/SYCL.cpp:682

  • This makes libclang_rt.builtins.bc mandatory for every SPIR/SPIR-V compilation, but sycl/CMakeLists.txt still builds and deploys it only when a SPIR-V compiler-rt target happens to be configured. A toolchain configured without that optional runtime now reports err_drv_no_sycl_device_lib for ordinary SYCL compilation, while the previous fallback definitions have been removed. Make compiler-rt a configure-time requirement or retain/select a valid fallback when the library is unavailable.
                                             "libsycl-imf",
                                             "libclang_rt.builtins"};
  • Files reviewed: 17/18 changed files
  • Comments generated: 2
  • Review effort level: Balanced

Comment on lines +311 to +314
if (!TC.getTriple().isSPIROrSPIRV())
return;
SmallString<128> SPIRVCompilerRTPath(TC.getCompilerRTPath());
llvm::sys::path::append(SPIRVCompilerRTPath, "spirv64-unknown-unknown");

@jinge90 jinge90 Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, all device libraries only provide spir64 versions, we don't support 32-bit.

Comment on lines +808 to +809
"libsycl-imf",
"libclang_rt.builtins"};

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will always build compiler-rt for spirv64 targets in intel/llvm sycl compiler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants