Skip to content

[SYCL][NewOffloadModel] Refactor SYCL pipeline in clang-linker-wrapper - #22153

Merged
sarnex merged 11 commits into
intel:syclfrom
maksimsab:sycl-no-rdc-new-offload/refactor-clang-linker-wrapper
Jun 11, 2026
Merged

[SYCL][NewOffloadModel] Refactor SYCL pipeline in clang-linker-wrapper#22153
sarnex merged 11 commits into
intel:syclfrom
maksimsab:sycl-no-rdc-new-offload/refactor-clang-linker-wrapper

Conversation

@maksimsab

@maksimsab maksimsab commented May 28, 2026

Copy link
Copy Markdown
Contributor

Extract SYCL offloading steps into named functions within the sycl namespace: runSYCLOffloadingPipeline, postLinkProcessModule, compileAndBundle and compileSYCLDevice.

SYCL modifications of linkDevice function has been extracted to the dedicated function - compileSYCLDevice.

Revert linkDevice function to its upstream state. Side effect of this revert: hipspv tests get resolved. Related tracker: CMPLRLLVM-73247

generic::clang declaration is reverted to its upstream variant. IsSYCLKind is replaced with ActiveOffloadKindMask.

Functions containerizeRawImage and writeOffloadFile are moved so that their location corresponds to the upstream version.

Extract SYCL offloading steps into named functions within the sycl
namespace: runSYCLOffloadingPipeline, postLinkProcessModule,
compileAndBundle and compileSYCLDevice.

SYCL modifications of linkDevice function has been extracted to the
dedicated function - compileSYCLDevice.

Revert linkDevice function to its upstream state. Side effect of this
revert: hipspv tests get resolved. Related tracker: CMPLRLLVM-73247

Functions containerizeRawImage and writeOffloadFile are moved so that
their location corresponds to the upstream version.
@maksimsab
maksimsab requested review from a team as code owners May 28, 2026 12:49
@maksimsab

maksimsab commented May 28, 2026

Copy link
Copy Markdown
Contributor Author

Note: this refactoring is done in scope of the adding the support for -fno-sycl-rdc for NewOffloadModel. The added function postLinkProcessModule is going to be invoked for every input module in the following patch as follows (processSYCLModule is the equivalent of postLinkProcessModule):
https://github.com/maksimsab/llvm/blob/19d314d7db175e6e96a05d048126c7c9a9b3cb51/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp#L2018-L2029

@maksimsab maksimsab added the new-offload-model Enables testing with NewOffloadModel. label May 28, 2026
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated

@YuriPlyakhin YuriPlyakhin 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.

quite a lot of CI failed. Is it caused by this patch?

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
@YuriPlyakhin

Copy link
Copy Markdown
Contributor

Revert linkDevice function to its upstream state. Side effect of this revert: hipspv tests get resolved. Related tracker: CMPLRLLVM-73247

Functions containerizeRawImage and writeOffloadFile are moved so that their location corresponds to the upstream version.

thank you for aligning the code to upstream!

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

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.

Pull request overview

This PR refactors the SYCL offloading flow in clang-linker-wrapper by extracting the SYCL-specific pipeline into named helper functions under the sycl namespace, while restoring the non-SYCL linkDevice path closer to upstream behavior. It also re-enables two HIPSPV driver tests by removing blanket XFAIL markers.

Changes:

  • Extract SYCL pipeline steps into sycl::runSYCLOffloadingPipeline, sycl::postLinkProcessModule, and related helpers (including compileSYCLDevice).
  • Revert/refactor the generic linkDevice path and relocate containerizeRawImage / writeOffloadFile to align with upstream structure.
  • Remove // XFAIL: * from HIPSPV toolchain/linking driver tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Refactors SYCL offloading into helper functions and adjusts device linking/wrapping flow.
clang/test/Driver/hipspv-toolchain.hip Removes global XFAIL to re-enable the test.
clang/test/Driver/hipspv-link-static-library.hip Removes global XFAIL to re-enable the test.

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
maksimsab added 3 commits June 2, 2026 05:41
remove subtle bug in sycl::wrapSYCLBinariesFromFile when Compile/Link options are moved out from the incoming images.
rename function compileSYCLDevice to invokeBackendForSYCLDevice and make it accept only one file.
rename function compileAndBundle to compileDeviceAndBundleNVPTXAndAMDGCN
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
@maksimsab
maksimsab requested a review from YuriPlyakhin June 8, 2026 11:43
@maksimsab

Copy link
Copy Markdown
Contributor Author

@YuriPlyakhin @mdtoguchi @srividya-sundaram friendly ping.

// RUN: %t.without_triple.o -o %t.out 2>&1 --linker-path="/usr/bin/ld" | FileCheck %s --check-prefix=CHECK-ERROR-WITH-NO-TRIPLE

// CHECK-ERROR-WITH-NO-TRIPLE: linking is not supported
// CHECK-ERROR-WITH-NO-TRIPLE: can't compile a SYCL device code. target is unknown

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.

not related to this PR, but a note for future PRs: this test should move to clang/test/OffloadTools/clang-linker-wrapper

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.

Good idea. We should move this part soon.

// RUN: --bitcode-library=spir64_gen-unknown-unknown=%t1.devicelib.bc \
// RUN: %t.wrong_spirv_subarch.o -o %t.out 2>&1 --linker-path="/usr/bin/ld" | FileCheck %s --check-prefix=CHECK-ERROR-WITH-WRONG-SPIRV-SUBARCH

// CHECK-ERROR-WITH-WRONG-SPIRV-SUBARCH: SYCL device compilation is not supported for the target: spirv64v1.0 No newline at end of file

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.

nit: please restore newline at end of file

@YuriPlyakhin YuriPlyakhin 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.

LGTM (one nit)

@maksimsab

Copy link
Copy Markdown
Contributor Author

@intel/llvm-gatekeepers Could we please merge that?

Failing tests are tracked here: #22295

@sarnex
sarnex merged commit 459650d into intel:sycl Jun 11, 2026
30 of 37 checks passed
@KornevNikita

Copy link
Copy Markdown
Contributor

These failures are unrelated to this patch?

@sarnex

sarnex commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Yeah, they only fail in new offload model testing which is disabled by default and only run in the nightly, and the nightly is already seeing these failures

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

Labels

new-offload-model Enables testing with NewOffloadModel.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants