Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3724d3c
llvm-patches: stop preserving device debug info on LLVM 21 and 22
pvelesko Aug 3, 2026
cc5558b
llvm-patches: add the LLVM 23 patch series
pvelesko Aug 3, 2026
0850562
scripts: support --version 23 in configure_llvm.sh
pvelesko Aug 3, 2026
5d7c1ca
Drop LLVM 20 support
pvelesko Aug 3, 2026
34ff7f4
docs: state where device debug info actually works
pvelesko Aug 3, 2026
eb05c96
unit_tests.sh: select the LLVM 23 SPIR-V producer with a flag, not a …
pvelesko Aug 3, 2026
7f8495d
ci: build and install LLVM 23, drop LLVM 20
pvelesko Aug 3, 2026
86808a2
ci: move the remaining LLVM 20 references off 20
pvelesko Aug 3, 2026
f5f5531
ci: test the LLVM toolchain that was just built, not the installed one
pvelesko Aug 3, 2026
ce2feda
llvm-patches: let the SPIR-V backend emit subgroup ops at SPIR-V 1.2
pvelesko Aug 3, 2026
dc9de3b
Fix remaining isZeroValue() in HipPrintf for LLVM 23
pvelesko Mar 12, 2026
c6ce1c1
Exclude ROCm-Device-Libs constant_fold test from CTest
pvelesko Mar 12, 2026
d286f62
promoteInt tests: fall back to in-tree SPIR-V backend
pvelesko Jun 7, 2026
1755b8c
samples: skip -fsycl interop samples on LLVM 23+
pvelesko Jun 13, 2026
0746139
Pass -fno-integrated-objemitter in translator mode on LLVM 23
pvelesko Jul 22, 2026
c71eb54
Fix use-after-free in per-thread queue teardown
pvelesko Mar 11, 2026
5ab18e5
HipPrintf: lower single device printf (fixes device-side assert)
pvelesko Jun 14, 2026
edca004
llvm-patches: stop preserving device debug info on LLVM 23 too
pvelesko Aug 4, 2026
ef8fcf1
Revert "llvm-patches: stop preserving device debug info on LLVM 23 too"
pvelesko Aug 4, 2026
a6efb89
Add stripDeviceDebugInfo() for removing SPIR-V debug information
pvelesko Aug 3, 2026
b81ce6a
Keep device debug info only on Intel Data Center GPU Max
pvelesko Aug 3, 2026
ac51450
bitcode: emit rtdevlib SPIR-V with a plain spirv64 triple
pvelesko Aug 4, 2026
66c6f6e
ci: use the fixed IGC build for the LLVM patch test lanes
pvelesko Aug 4, 2026
4a23472
llvm-patches: backport ExpandVariadics printf fix to LLVM 23
pvelesko Aug 4, 2026
3061eb5
llvm-patches: guard SPIRVEmitIntrinsics getArg for variadic callees
pvelesko Aug 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
llvm-version: [20]
llvm-version: [21]
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -127,7 +127,7 @@ jobs:
matrix:
include:
- pocl-version: "7.1"
llvm-version: 20
llvm-version: 21
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -202,7 +202,7 @@ jobs:
# PoCL backend with specific version combinations
- backend: pocl
pocl-version: "7.1"
llvm-version: 20
llvm-version: 21
extra_exclude: ""
fail-fast: false
steps:
Expand Down
80 changes: 67 additions & 13 deletions .github/workflows/test-llvm-patches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ jobs:
strategy:
matrix:
include:
- llvm-version: 20
build-id: "20"
install-suffix: ""
variant-flag: ""
- llvm-version: 21
build-id: "21"
install-suffix: ""
Expand All @@ -44,6 +40,13 @@ jobs:
build-id: "22-native"
install-suffix: "-native"
variant-flag: "--variant native"
# LLVM 23 needs only one build: chipStar patches in llvm#213052, so the
# SPIRV-target build also serves the translator and the producer is
# chosen per compilation by -f[no-]integrated-objemitter.
- llvm-version: 23
build-id: "23"
install-suffix: ""
variant-flag: "--variant native"
fail-fast: true
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -82,9 +85,6 @@ jobs:
strategy:
matrix:
include:
- llvm-version: 20
build-id: "20"
install-suffix: ""
- llvm-version: 21
build-id: "21"
install-suffix: ""
Expand All @@ -94,6 +94,9 @@ jobs:
- llvm-version: 22
build-id: "22-native"
install-suffix: "-native"
- llvm-version: 23
build-id: "23"
install-suffix: ""
fail-fast: false
steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -139,8 +142,30 @@ jobs:
# install-only runtime headers such as omp.h, which made
# TestHipccFopenmp fail with "'omp.h' file not found".
LLVM_PREFIX="$HOME/install/llvm/${{ matrix.llvm-version }}.0${{ matrix.install-suffix }}"
LLVM_BIN="$HOME/llvm-stage/${{ matrix.build-id }}${LLVM_PREFIX}/bin"
LLVM_STAGE="$HOME/llvm-stage/${{ matrix.build-id }}${LLVM_PREFIX}"
LLVM_BIN="${LLVM_STAGE}/bin"
test -f "${LLVM_BIN}/clang" || exit 1

# The staged binaries are thin drivers; all the driver logic lives in
# libclang-cpp.so / libLLVM.so. Their RUNPATH points at the *final*
# install prefix ($HOME/install/llvm/<ver>), not at the stage, so by
# default the staged clang loads the previously installed libraries
# and silently runs old code. That makes this lane test the installed
# toolchain rather than the one just built from llvm-patches/, which
# is precisely what this workflow exists to validate. Pin the loader
# to the stage, and persist it to the test steps via GITHUB_ENV since
# chipStar invokes clang again at test time.
export LD_LIBRARY_PATH="${LLVM_STAGE}/lib:${LLVM_STAGE}/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
echo "LD_LIBRARY_PATH=${LD_LIBRARY_PATH}" >> "$GITHUB_ENV"

# Fail loudly if the pin did not take effect, rather than silently
# validating the wrong toolchain again.
RESOLVED=$(ldd "${LLVM_BIN}/clang" 2>/dev/null | awk '/libclang-cpp/{print $3}')
case "$RESOLVED" in
"${LLVM_STAGE}"/*) echo "OK: clang resolves libclang-cpp from the stage" ;;
"") echo "NOTE: clang does not link libclang-cpp dynamically; nothing to pin" ;;
*) echo "ERROR: clang resolves libclang-cpp from '$RESOLVED', not the stage"; exit 1 ;;
esac
test -f "${LLVM_BIN}/../lib/clang/${{ matrix.llvm-version }}/include/omp.h" \
|| { echo "ERROR: omp.h missing from LLVM install toolchain at ${LLVM_BIN}"; exit 1; }
cd ${{ github.workspace }}
Expand All @@ -162,6 +187,9 @@ jobs:
elif [ -f /etc/profile.d/lmod.sh ]; then source /etc/profile.d/lmod.sh &> /dev/null
else source /etc/profile.d/modules.sh &> /dev/null; fi
module use ~/modulefiles
# IGC 2.36.3/2.38.2 miscompile chipStar kernels under their
# optimizer (TestSnakeMiscompileO2); this build carries the fix.
module load igc/all-fixes-2026.07.30
module load opencl/igpu
cd ${{ github.workspace }}/build-llvm${{ matrix.build-id }}
../scripts/check.py ./ igpu opencl
Expand All @@ -175,6 +203,9 @@ jobs:
elif [ -f /etc/profile.d/lmod.sh ]; then source /etc/profile.d/lmod.sh &> /dev/null
else source /etc/profile.d/modules.sh &> /dev/null; fi
module use ~/modulefiles
# IGC 2.36.3/2.38.2 miscompile chipStar kernels under their
# optimizer (TestSnakeMiscompileO2); this build carries the fix.
module load igc/all-fixes-2026.07.30
module load level-zero/igpu
cd ${{ github.workspace }}/build-llvm${{ matrix.build-id }}
../scripts/check.py ./ igpu level0
Expand All @@ -187,6 +218,9 @@ jobs:
elif [ -f /etc/profile.d/lmod.sh ]; then source /etc/profile.d/lmod.sh &> /dev/null
else source /etc/profile.d/modules.sh &> /dev/null; fi
module use ~/modulefiles
# IGC 2.36.3/2.38.2 miscompile chipStar kernels under their
# optimizer (TestSnakeMiscompileO2); this build carries the fix.
module load igc/all-fixes-2026.07.30
module load level-zero/dgpu
cd ${{ github.workspace }}/build-llvm${{ matrix.build-id }}
../scripts/check.py ./ dgpu level0
Expand All @@ -199,6 +233,9 @@ jobs:
elif [ -f /etc/profile.d/lmod.sh ]; then source /etc/profile.d/lmod.sh &> /dev/null
else source /etc/profile.d/modules.sh &> /dev/null; fi
module use ~/modulefiles
# IGC 2.36.3/2.38.2 miscompile chipStar kernels under their
# optimizer (TestSnakeMiscompileO2); this build carries the fix.
module load igc/all-fixes-2026.07.30
module load opencl/dgpu
cd ${{ github.workspace }}/build-llvm${{ matrix.build-id }}
../scripts/check.py ./ dgpu opencl
Expand All @@ -211,6 +248,9 @@ jobs:
elif [ -f /etc/profile.d/lmod.sh ]; then source /etc/profile.d/lmod.sh &> /dev/null
else source /etc/profile.d/modules.sh &> /dev/null; fi
module use ~/modulefiles
# IGC 2.36.3/2.38.2 miscompile chipStar kernels under their
# optimizer (TestSnakeMiscompileO2); this build carries the fix.
module load igc/all-fixes-2026.07.30
module load opencl/cpu
cd ${{ github.workspace }}/build-llvm${{ matrix.build-id }}
../scripts/check.py ./ cpu opencl --num-tries=3
Expand All @@ -233,10 +273,6 @@ jobs:
strategy:
matrix:
include:
- llvm-version: 20
build-id: "20"
install-suffix: ""
module-name: "20.0"
- llvm-version: 21
build-id: "21"
install-suffix: ""
Expand All @@ -249,6 +285,10 @@ jobs:
build-id: "22-native"
install-suffix: "-native"
module-name: "22.0-native"
- llvm-version: 23
build-id: "23"
install-suffix: ""
module-name: "23.0"
fail-fast: false
steps:
- name: Install LLVM ${{ matrix.build-id }}
Expand Down Expand Up @@ -415,11 +455,25 @@ jobs:
# the build tree, which lacks install-only runtime headers such as
# omp.h (breaks TestHipccFopenmp with "'omp.h' file not found").
LLVM_PREFIX="$HOME/install/llvm/22.0-${{ matrix.variant }}"
LLVM_BIN="$HOME/llvm-stage/22-${{ matrix.variant }}${LLVM_PREFIX}/bin"
LLVM_STAGE="$HOME/llvm-stage/22-${{ matrix.variant }}${LLVM_PREFIX}"
LLVM_BIN="${LLVM_STAGE}/bin"
test -f "${LLVM_BIN}/clang" || exit 1
test -f "${LLVM_BIN}/../lib/clang/22/include/omp.h" \
|| { echo "ERROR: omp.h missing from LLVM install toolchain at ${LLVM_BIN}"; exit 1; }

# configure_llvm.sh builds with LLVM_LINK_LLVM_DYLIB=ON and
# CMAKE_INSTALL_RPATH pinned to the final install prefix, so a staged
# (DESTDIR) clang resolves libclang-cpp/libLLVM from the previously
# installed toolchain and runs old driver code. Pin the loader to the
# stage so this lane tests what it just built. DYLD_LIBRARY_PATH (not
# DYLD_FALLBACK_LIBRARY_PATH) is required: fallback is consulted only
# after @rpath resolution fails, and here it succeeds with the wrong
# library. Diagnostic only, not fatal, since the macOS linkage layout
# is not verified here the way the Linux one is.
export DYLD_LIBRARY_PATH="${LLVM_STAGE}/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}"
echo "clang links against:"
otool -L "${LLVM_BIN}/clang" 2>/dev/null | grep -iE "clang-cpp|libLLVM" || true

export PATH="/Users/paulius/.pyenv/shims:/opt/homebrew/bin:/opt/homebrew/sbin:$PATH"
export CHIP_DEVICE_TYPE=pocl
export OCL_ICD_VENDORS=/Users/paulius/install/pocl/etc/OpenCL/vendors/
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/x86-intel-gpu-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -474,38 +474,6 @@ jobs:
# debug builds. These run ONLY on a manual workflow_dispatch, not on every
# PR, to keep automatic CI fast. Automatic PRs cover llvm-22 native-release
# (Stage 1, above) and llvm-22 translator-release (below).
unit-tests-llvm-20-debug:
needs: build-and-test-libceed
if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' }}
runs-on: [self-hosted, Linux, X64]
env:
CHIP_MODULE_CACHE_DIR: ""
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
submodules: 'recursive'
- name: Run unit test checking script
run: ./scripts/unit_tests.sh debug llvm-20
shell: bash

unit-tests-llvm-20-release:
needs: build-and-test-libceed
if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' }}
runs-on: [self-hosted, Linux, X64]
env:
CHIP_MODULE_CACHE_DIR: ""
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0
submodules: 'recursive'
- name: Run unit test checking script
run: ./scripts/unit_tests.sh release llvm-20
shell: bash

unit-tests-llvm-21-debug:
needs: build-and-test-libceed
if: ${{ !cancelled() && github.event_name == 'workflow_dispatch' }}
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ include(LLVMCheck)
include(chip_spv_cmake_macros)
enable_testing()

# Exclude ROCm-Device-Libs tests that target amdgcn (not applicable to SPIR-V builds).
file(WRITE "${CMAKE_BINARY_DIR}/CTestCustom.cmake"
"set(CTEST_CUSTOM_TESTS_IGNORE \"constant_fold_lgamma_r\")\n")

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "..." FORCE)
endif()
Expand Down Expand Up @@ -381,6 +385,10 @@ endif()
set(SPIRV_EMITTER_OPTS "")
if(CHIP_LLVM_USE_INTERGRATED_SPIRV)
set(SPIRV_EMITTER_OPTS "-fintegrated-objemitter")
elseif(LLVM_VERSION_MAJOR GREATER_EQUAL 23)
# LLVM 23's HIPSPV toolchain defaults to the in-tree SPIR-V backend when it
# is built; explicitly request the llvm-spirv translator.
set(SPIRV_EMITTER_OPTS "-fno-integrated-objemitter")
endif()

if(CHIP_VERBOSE)
Expand Down
2 changes: 1 addition & 1 deletion MacOS-Issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ For macOS development, use **Option A** (dynamic LLVM). The `configure_llvm.sh`

### Required Dependencies
- Homebrew packages: `spirv-tools`, `cmake`, `ninja`
- Environment modules: `llvm/20.0` (or newer), `ocl-icd-loader`, `pocl`
- Environment modules: `llvm/22.0` (or newer), `ocl-icd-loader`, `pocl`

### Build Command
```bash
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ Release notes for [1.3](docs/release_notes/chipStar_1.3.rst), [1.2](docs/release
## Prerequisites

* Cmake >= 3.20.0
* Clang and LLVM 20, 21, 22 (plus an experimental `latest` option tracking the maintained [chipStar-llvm-23](https://github.com/CHIP-SPV/llvm-project/tree/chipStar-llvm-23) branch)
* Can be installed, for example, by adding the [LLVM's Debian/Ubuntu repository](https://apt.llvm.org/) and installing packages 'clang-20 llvm-20 clang-tools-20'.
* Clang and LLVM 21, 22, 23 (plus an experimental `latest` option tracking the maintained [chipStar-llvm-23](https://github.com/CHIP-SPV/llvm-project/tree/chipStar-llvm-23) branch)
* Can be installed, for example, by adding the [LLVM's Debian/Ubuntu repository](https://apt.llvm.org/) and installing packages 'clang-21 llvm-21 clang-tools-21'.
* For the best results, build Clang/LLVM with the chipStar patches applied (from `llvm-patches/llvm-<version>/`). See below for a scripted way to build and install the patched versions.
* SPIRV-LLVM-Translator from a branch matching the LLVM major version:
(e.g. llvm\_release\_200 for LLVM 20, llvm\_release\_210 for LLVM 21)
(e.g. llvm\_release\_210 for LLVM 21, llvm\_release\_220 for LLVM 22)
, [llvm-spirv](https://github.com/KhronosGroup/SPIRV-LLVM-Translator).
* Make sure the built llvm-spirv binary is installed into the same path as clang binary, otherwise clang might find and use a different llvm-spirv, leading to errors.
* SPIRV-Tools and SPIRV-Headers:
Expand All @@ -101,26 +101,26 @@ For this you can use a script included in the chipStar repository:
```bash
./scripts/configure_llvm.sh
Usage: ./scripts/configure_llvm.sh --version <version> --install-dir <dir> --link-type static/dynamic(default) [--variant translator|native] [--with-binutils [path]] [--configure-only] [-N]
--version: LLVM version 20, 21, 22, or latest (experimental, tracks the maintained chipStar-llvm-23 branch, no patches)
--version: LLVM version 21, 22, 23, or latest (experimental, tracks the maintained chipStar-llvm-23 branch, no patches)
--install-dir: installation directory
--link-type: static or dynamic (default: dynamic)

./scripts/configure_llvm.sh --version 20 --install-dir /opt/install/llvm/20.0
cd llvm-project/llvm/build_20
./scripts/configure_llvm.sh --version 22 --install-dir /opt/install/llvm/22.0
cd llvm-project/llvm/build_22
make -j 16
<sudo> make install
```

Or you can do the steps manually (clone the release branches, apply the patches from `llvm-patches/llvm-<version>/`, then build):

```bash
git clone --depth 1 https://github.com/llvm/llvm-project.git -b release/20.x
git clone --depth 1 https://github.com/llvm/llvm-project.git -b release/22.x
cd llvm-project
for p in /path/to/chipStar/llvm-patches/llvm-20/llvm/*.patch; do git apply "$p"; done
for p in /path/to/chipStar/llvm-patches/llvm-22/llvm/*.patch; do git apply "$p"; done
cd llvm/projects
git clone --depth 1 https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git -b llvm_release_200
git clone --depth 1 https://github.com/KhronosGroup/SPIRV-LLVM-Translator.git -b llvm_release_220
cd SPIRV-LLVM-Translator
for p in /path/to/chipStar/llvm-patches/llvm-20/spirv-translator/*.patch; do git apply "$p"; done
for p in /path/to/chipStar/llvm-patches/llvm-22/spirv-translator/*.patch; do git apply "$p"; done
cd ../../..

# DLLVM_ENABLE_PROJECTS="clang;openmp" OpenMP is optional but many apps use it
Expand All @@ -131,7 +131,7 @@ cmake -S llvm -B build \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang;openmp" \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DCMAKE_INSTALL_PREFIX=$HOME/local/llvm-20
-DCMAKE_INSTALL_PREFIX=$HOME/local/llvm-22
make -C build -j8 all install
```

Expand Down
9 changes: 8 additions & 1 deletion bitcode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,15 @@ function(embed_spirv_in_cpp
OUTPUT "${OUTPUT_SOURCE}" "${OUTPUT_HEADER}"
DEPENDS "${BC_SOURCE}"
BYPRODUCTS "${SPIR_BINARY}"
# NOTE: the triple must NOT carry the "chipstar" OS component here.
# spirv64vX-unknown-chipstar selects the HIPSPV toolchain, whose -c
# action emits LLVM bitcode for the offload driver to link later; it
# exits 0, so the ".spv" silently contains "BC\xc0\xde" instead of
# SPIR-V and every clLinkProgram() of the rtdevlib fails with
# CL_LINK_PROGRAM_FAILURE / CL_INVALID_PROGRAM. The plain spirv64vX
# triple selects the SPIRV toolchain, which emits SPIR-V directly.
COMMAND "${CMAKE_CXX_COMPILER}"
--target=spirv64v${MAX_SPIRV_VERSION}-unknown-chipstar
--target=spirv64v${MAX_SPIRV_VERSION}
-mllvm -spirv-ext=${SPIRV_EXTENSIONS}
-c -x ir
"${BC_SOURCE}" -o "${SPIR_BINARY}"
Expand Down
4 changes: 2 additions & 2 deletions cmake/LLVMCheck.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
if((CMAKE_CXX_COMPILER_ID MATCHES "[Cc]lang") OR
(CMAKE_CXX_COMPILER_ID MATCHES "IntelLLVM"))

if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 20.0.0)
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 21.0.0)
message(FATAL_ERROR
"Unsupported clang version '${CMAKE_CXX_COMPILER_VERSION}'. "
"chipStar requires clang/LLVM 20, 21, or 22 (or the experimental "
"chipStar requires clang/LLVM 21, 22, or 23 (or the experimental "
"'latest' toolchain); see scripts/configure_llvm.sh.")
endif()
else()
Expand Down
Loading
Loading