Skip to content

Adjustments for Clang's new offload driver#1114

Closed
linehill wants to merge 1 commit intoCHIP-SPV:mainfrom
linehill:clang-new-offload-driver
Closed

Adjustments for Clang's new offload driver#1114
linehill wants to merge 1 commit intoCHIP-SPV:mainfrom
linehill:clang-new-offload-driver

Conversation

@linehill
Copy link
Collaborator

@linehill linehill commented Dec 4, 2025

This patch updates chipStar to use Clang's new offload driver for the next LLVM release version 22. The old/current driver one may be removed in Clang in the future, rendering HIPSPV toolchain inoperable.

This patch depends on the following things:

Upstreaming patches of chipStar's LLVM fork

After the LLVM patch is merged, chipStar should no longer need to depend on chipStar's LLVM fork for the future LLVM releases. Couple commits are omitted in the upstream LLVM patch:

@pvelesko
Copy link
Collaborator

pvelesko commented Dec 4, 2025

fyi, we no longer use branches for LLVM instead we have a series of patches that we apply to mainline LLVM. @linehill

@linehill
Copy link
Collaborator Author

linehill commented Dec 4, 2025

fyi, we no longer use branches for LLVM instead we have a series of patches that we apply to mainline LLVM. @linehill

Right, but those patches are used to build chipStar's variant of LLVM - IOW, a fork of LLVM? Anyway, the upstream LLVM patch should make them obsolete too (unless one really need the device side debug info).

This patch updates chipStar to use Clang's new offload driver for the
next LLVM release version 22. The old/current driver one may be
removed in Clang in the future, rendering HIPSPV toolchain inoperable.

This patch depends on the following things:

* An upstream LLVM patch whose review is ongoing
  llvm/llvm-project#168043. In the meanwhile this patch can be tried
  out using [my branch](
  https://github.com/linehill/llvm-project/tree/hipspv-new-offload-driver). This
  patch also upstream changes from chipStar's LLVM fork - more details
  in the below.

* The following
  [ROCm-DeviceLib](https://github.com/linehill/ROCm-Device-Libs/tree/clang-new-offload-driver)
  and [HIPCC](https://github.com/linehill/HIPCC/tree/clang-new-offload-driver)
  submodules updates. The submodules are temporarily tracking the
  revisions from my repositories - I'll update them once the changes
  have landed on the respective CHIP-SPV repositories.

Upstreaming patches of chipStar's LLVM fork

After the LLVM patch is merged, chipStar should no longer need to
depend on chipStar's LLVM fork for the future LLVM releases. Couple
commits are omitted in the upstream LLVM patch:

* SPIR-V datalayout change: an alternate fix is proposed for
  CHIP-SPV/ROCm-Device-Lib.

* Enabling debug info for the device code: SPIR-V LLVM Translator
  doesn't yet robustly handle debug info
  (KhronosGroup/SPIRV-LLVM-Translator#3247).
@linehill linehill force-pushed the clang-new-offload-driver branch from 87e96f3 to d283a8a Compare December 5, 2025 07:24
pvelesko added a commit that referenced this pull request Feb 1, 2026
LLVM 22 compatibility changes:
- Replace getNextNonDebugInstruction() with getNextNode() in HipAbort.cpp
  (debug info moved from intrinsics to records in LLVM 22)
- Update PassPlugin.h include path for LLVM 22 (llvm/Plugins/ vs llvm/Passes/)
- Update SPIR-V data layout in irif .ll files to match LLVM 22 spirv64 target
- Add LLVM 22 version to configure_llvm.sh

New offload driver integration (from PR #1114):
- Add HAVE_CLANG_NEW_OFFLOAD_DRIVER and USE_NEW_OFFLOAD_DRIVER CMake options
- Add OFFLOAD_TRIPLE for spirv64v1.2-unknown-chipstar target
- Update bitcode CMakeLists.txt for new triple handling
- Add stub functions for __hipRegisterTexture, __hipRegisterManagedVar,
  __hipRegisterSurface in CHIPBindings.cc

Note: Old offload driver works with LLVM 22. New offload driver has
spirv-link compatibility issues (Schema is non-zero error) that need
further investigation.
pvelesko added a commit that referenced this pull request Feb 2, 2026
LLVM 22 compatibility changes:
- Replace getNextNonDebugInstruction() with getNextNode() in HipAbort.cpp
  (debug info moved from intrinsics to records in LLVM 22)
- Update PassPlugin.h include path for LLVM 22 (llvm/Plugins/ vs llvm/Passes/)
- Update SPIR-V data layout in irif .ll files to match LLVM 22 spirv64 target
- Add LLVM 22 version to configure_llvm.sh

New offload driver integration (from PR #1114):
- Add HAVE_CLANG_NEW_OFFLOAD_DRIVER and USE_NEW_OFFLOAD_DRIVER CMake options
- Add OFFLOAD_TRIPLE for spirv64v1.2-unknown-chipstar target
- Update bitcode CMakeLists.txt for new triple handling
- Add stub functions for __hipRegisterTexture, __hipRegisterManagedVar,
  __hipRegisterSurface in CHIPBindings.cc

Note: Old offload driver works with LLVM 22. New offload driver has
spirv-link compatibility issues (Schema is non-zero error) that need
further investigation.
@pvelesko
Copy link
Collaborator

Closing in favor of #1140

Which adds support for the new offload driver + chooses native SPIR-V backend over the translator when available.

@linehill Please let me know if there's anything missing in that branch.

@pvelesko pvelesko closed this Feb 16, 2026
@linehill
Copy link
Collaborator Author

Closing in favor of #1140

Alright, but not sure why changes in this PR needed to be crammed into #1140.

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

Comments