Skip to content

LLVM and SPIRV-LLVM-Translator pulldown (WW12 2026)#21560

Draft
iclsrc wants to merge 3139 commits intosyclfrom
llvmspirv_pulldown
Draft

LLVM and SPIRV-LLVM-Translator pulldown (WW12 2026)#21560
iclsrc wants to merge 3139 commits intosyclfrom
llvmspirv_pulldown

Conversation

@iclsrc
Copy link
Collaborator

@iclsrc iclsrc commented Mar 19, 2026

jhuber6 and others added 30 commits March 5, 2026 12:30
Summary:
This implementation only worked if the lane mask passed in was uniform,
but this is against the expected usage where the user may be wishing to
check if a value is uniform *within* a mask subset. Also remove
redundant sync_lanes, the ballots and shuffles already have
synchronizing behavior.
… HLSL casts in the new constant interpreter for basic matrix constexpr evaluation in HLSL (#184840)

Forgot to change the target branch before merging. This PR is a
cherry-pick of the squashed-and-merged PR commit
b16aa4b7ec665911c74300cd7442659b70973d13 from 183424

This PR fixes #182963
This PR is an extension of #178762 which has already been merged.

This PR adds support for `ConstantMatrixType` and the HLSL casts
`CK_HLSLArrayRValue`, `CK_HLSLMatrixTruncation`,
`CK_HLSLAggregateSplatCast`, and `CK_HLSLElementwiseCast` to the
bytecode constexpr evaluator.

The implementations of CK_HLSLAggregateSplatCast and
CK_HLSLElementwiseCast are incomplete, as they still need to support
struct and array types to enable use of the experimental new constant
interpreter on other existing HLSL constexpr tests. The completion of
the implementations of these casts will be tracked in a separate issue
(#183426) and implemented in a separate PR.

Assisted-by: claude-opus-4.6
* This will allow us to setup clang-stage1-RA jobs as multi branch
pipelines for release branches without setting up all the downstream
jobs.

I will need to cherry-pick the jenkinsfile to the release/22.x branch
which I will do after this lands
Moving getResidentPages out of linux.cpp and adding it to MemMapBase
…_TYPE` (#184793)

The `ASSIGN_TYPE` instruction should not be referenced anymore at this
point. So we can free its memory.

Follow up of llvm/llvm-project#182330
…#184843)

Reverts llvm/llvm-project#183794

It broke a couple of tests from Fujitsu testsuite.
returning anything from the callback.  Fixing this on the off
chance that is what is causing the linux-only failure in this test
after PR:

llvm/llvm-project#184272
…classes (#182706)

Inherited constructors in `dllexport` classes are now exported for ABI-compatible cases, 
matching MSVC behavior. Constructors with variadic arguments or callee-cleanup 
parameters are not yet supported and produce a warning.

This aims to partially resolve llvm/llvm-project#162640.

Assisted by : Cursor // Claude Opus 4.6
Add additional tests with multiple argmin/argmax reductions for
llvm/llvm-project#184729.
…ment. (#184839)

We don't have instructions for an i8 sshlat.
This just adds this as an NYI, but this will suppress the Wswitch
warning.
…#184714)

Replace "compile" with "assemble" in formatter_bytecode. This is in
preparation for the addition of a Python to formatter bytecode compiler.
It will be more clear to have one meaning for "compile".
…yFixIrreducibleControlFlow" (#181755) (#184441)

Re-application of #181755.

Includes fixes to issues found after the original's merge.
…84853)

It is a convention to use uppercase names of directives and clauses in
diagnostic messages, but getting such names is somewhat cumbersome:
```
parser::ToUpperCaseLetters(llvm::omp::getOpenMPDirectiveName(dirId));
parser::ToUpperCaseLetters(llvm::omp::getOpenMPClauseName(clauseId));
```

Implement `GetUpperName` (overloaded for clauses and directives) to
shorten it to
```
GetUpperName(dirId, version);
GetUpperName(clauseId, version);
```

This patch replaces existing instances of this pattern, adding the use
of OpenMP version where it was previously missing.
This is a speculative fix for the openmp-offload-sles-build-only build
bot that fails after #184376 with:

```
clang/lib/Tooling/DependencyScanningTool.cpp:336:12: error: could not convert ‘CIWithContext’ from ‘clang::tooling::CompilerInstanceWithContext’ to ‘std::optional<clang::tooling::CompilerInstanceWithContext>’
     return CIWithContext;
            ^~~~~~~~~~~~~
```
…#179568)

Fixes #168944 
Depends on #178762 being merged first.

The commit adds implicit conversion warnings for HLSL matrix types in
Clang's semantic checker by extending SemaChecking.cpp to detect
precision loss when converting between matrix types (specifically,
ConstantMatrixType).
A new test validates float precision warnings, and an existing test was
updated to expect the new diagnostics.

Assisted-by: claude-opus-4.5
to see the private state to do so until we are done hijacking.
Avoid error like: 

```
error: runtime derived type info descriptor was not generated 
```
Some compilers (e.g. on AIX) do not pack by default. Use LLVM_PACKED to
ensure the VPIRFlags struct is packed as expected on all platforms.

This matches what we already do in other places for AIX, e.g. in
llvm/include/llvm/CodeGen/SelectionDAGNodes.h (added in
844a02e), although it uses the more
general LLVM_PACKED unconditionally

PR: llvm/llvm-project#184687
Implicitly discovered module maps that reference files outside their
module directory cause order dependent behavior when using implicitly
discovered module maps. This adds an off by default diagnostic about
these cases with the long term goal of removing import order dependent
behavior.

Module maps found via `-fmodule-map-file=` are not a problem because
they are all loaded at the start of translation.

Assisted-by: claude-opus-4.6
  CONFLICT (content): Merge conflict in clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
…owed"

This reverts commit a8af467.

This was a follow-on to 97572c1 which was me
trying to guess why the ubuntu bots were failing with an entirely unhelpful
failure mode.  I'll have to figure out how I can reproduce this somewhere so
I can look at it for real.
This reverts commit 894408d.

These tests were added by 97572c1
and I am reverting that as well.
…tate" mode. (#184272)"

This reverts commit 97572c1.

This patch seems to cause TestWatchpointCommandPython.py to time out
on the ubuntu buildbots (but nowhere else that I can find so far.)  The
timeout is weird too, the TEST FILE is timing out but the individual
tests aren't being shown and there's no other output.  Grrr...
Anyway I'll revert this and then see if I can do some guessing about
how this change might cause the test to fail.
…ent (#184868)

Assume a sufficently new code object version if the environment is set
to something indicating we should have a real library.
…184836)

We only support splat shift amounts. Previously we checked if the shift
amount was a splat_vector and considered it legal.

I don't think there is a guarantee that the splat_vector will stick
around as a splat_vector. It's safer if we capture the splat and create
a dedicated node with a scalar shift amount.
sys-ce-bb and others added 10 commits March 20, 2026 19:41
…ies (#134805)" (#174483)

This reverts commit ccfb97b.

This was reverted due to the unfortunate reliance on external device
library installations, which ship the last rocm released bitcode. The
last attempt was 8 months ago, so hopefully the buildbots are now caught
up to a more recent build that no longer needs the old control library.
9bec7a5 revert the changes and removed the tests.
We did not remove the tests so it is failing.
Fix annotations-field.c tests that broke after commit
b3d99ac which changed Clang's CGBuilder to use DataLayout-aware
TargetFolder instead of ConstantFolder.

The commit causes GEP constant expressions to be emitted in canonical
getelementptr i8 form instead of typed form, and affects when the nuw
qualifier is emitted. Updated CHECK lines to reflect the new IR:
- Changed from typed GEPs like `getelementptr (%struct.foo, ...)`
  to canonical i8 form `getelementptr (i8, ptr, i64 offset)`

Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix extra warnings/errors like:

```
nblog2.log: 13595: In file included from /netbatch/build_comp63266_00/ics_top/llvm/llvm/include/llvm/IR/Metadata.h:35:
nblog2.log: 13596: /netbatch/build_comp63266_00/ics_top/llvm/llvm/include/llvm/ADT/ArrayRef.h:79:35: error: implicit conversion changes signedness: 'long' to 'size_type' (aka 'unsigned long') [-Werror,-Wsign-conversion]
nblog2.log: 13597:    79 |         : Data(begin), Length(end - begin) {
nblog2.log: 13598:       |                              ~~~~~^~~~~~~
nblog2.log: ...
nblog2.log: 13843: make[2]: *** [tools/sycl-jit/passes/CMakeFiles/SYCLJITPasses.dir/build.make:78: tools/sycl-jit/passes/CMakeFiles/SYCLJITPasses.dir/SYCLJITPasses.cpp.o] Error 1

```
@jsji jsji force-pushed the llvmspirv_pulldown branch from 043272e to 20925eb Compare March 21, 2026 02:44
sys-ce-bb and others added 4 commits March 20, 2026 20:48
…171b8d)

After the NVPTX refactoring in a171b8d and 21d93c2,
createNVVMInternalAddrspaceWrap unconditionally adds ReadOnly attribute
to byval parameters. This causes a verifier error for kernel parameters
with local_accessor (writable shared memory), which are already marked
writeonly by the frontend.

The fix checks for existing WriteOnly attribute before adding ReadOnly,
preventing the attribute conflict while preserving the readonly
optimization for truly read-only parameters.

Fixes compilation of structs_with_special_types_as_kernel_paramters.cpp
test which failed with:
  Attributes 'readonly and writeonly' are incompatible!

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
After the NVPTX refactoring in a171b8d, NVPTXLowerArgs unconditionally
adds grid_constant attribute to all byval parameters via createNVVMInternalAddrspaceWrap.
This causes issues with writeonly parameters (marked by SPIRV backend with
initializes attribute) that need to be written to for initialization.

The grid_constant attribute requires parameters to be read-only inputs in PTX
.param space, but writeonly parameters are outputs that must be written to.
This causes ptxas errors: "Illegal to write to function input parameter".

The fix ensures writeonly byval parameters:
1. Are forced to use copyByValParam (local memory copy) early in lowerKernelByValParam
2. Skip getting grid_constant/ReadOnly attributes in createNVVMInternalAddrspaceWrap

This allows writeonly parameters to be properly handled as outputs in local
memory where they can be written to, fixing compilation with -fsycl-use-spirv-backend-for-spirv-gen.

Fixes: structs_with_special_types_as_kernel_paramters.cpp test

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…sions

Fixes regression introduced by commit e56b580 "Reapply '[SPIRV]
Emit intrinsics for globals only in function that references them'".

Root cause:
- When globals are used in constant expressions (e.g., ptrtoint in another
  global's initializer), those expressions become OpSpecConstantOp during
  SPIRV lowering
- OpSpecConstantOp instructions need the global definitions to be available
- The original optimization only emitted globals in functions that directly
  reference them, missing the OpSpecConstantOp case

Minimal fix:
1. Fixed iterator initialization bug in collectGlobalUsers (line 76)
   - Changed: SmallVector<const Value *> Stack = {begin, end};  (WRONG)
   - To: SmallVector<const Value *> Stack(begin, end);  (CORRECT)

2. Track which globals are used by other globals (constant expressions)
   - Added isUsedByGlobalsWithNoFunctionUsers() method
   - Emit such globals in the first function (where module-level OpSpecConstantOp
     is processed)
   - Regular globals used by function-referenced globals: emit in those functions

This preserves the optimization for regular globals (only emit where used)
while fixing the regression for:
  - Metadata globals (e.g., @__TsanDeviceGlobalMetadata with ptrtoint)
  - Globals in function-referenced constant expressions (e.g., @p_var with GEP)

Test cases:
  - sycl/test-e2e/ThreadSanitizer/check_device_global.cpp
  - test/CodeGen/SPIRV/const-nested-vecs.ll

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jsji jsji force-pushed the llvmspirv_pulldown branch from 76a4166 to 7f4b166 Compare March 23, 2026 00:54
@jsji
Copy link
Contributor

jsji commented Mar 24, 2026

Commit e4c30c1 added ExpandVariadics pass which packs variadic function
arguments into struct buffers. This broke __spirv_ocl_printf in SPIRV backend
because the backend was passing struct pointers to OpExtInst printf, but printf
expects individual scalar value operands.

Fix by skipping __spirv_ocl_printf functions in ExpandVariadics pass, allowing
them to remain truly variadic and work with the SPIRV backend's native printf
handling. This is a targeted revert that only affects SPIRV printf functions
while keeping ExpandVariadics enabled for other variadic functions.

Also add defensive bounds checking in SPIRVModuleAnalysis to prevent crashes
when OpExtInst instructions have fewer operands than expected.

Fixes:
- Printf/char.cpp
- Printf/float.cpp
- Printf/double.cpp
- DeviceLib/built-ins/printf.cpp
- ThreadSanitizer/check_access16.cpp (no longer crashes)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@jsji jsji force-pushed the llvmspirv_pulldown branch from d8201f6 to 9165e9c Compare March 24, 2026 14:37
@sarnex
Copy link
Contributor

sarnex commented Mar 24, 2026

Will take look soon but not totally trivial changes

@jsji
Copy link
Contributor

jsji commented Mar 24, 2026

Will take look soon but not totally trivial changes

Thanks! I will XFAIL the new SPIRV/printf test first too to unblock pulldown, you can take your time to address them later.

@sarnex
Copy link
Contributor

sarnex commented Mar 24, 2026

Thanks

@jsji jsji force-pushed the llvmspirv_pulldown branch 3 times, most recently from a74645e to 8f94af9 Compare March 24, 2026 20:56
@jsji jsji force-pushed the llvmspirv_pulldown branch from 8f94af9 to 14c1992 Compare March 25, 2026 00:46
@jsji jsji force-pushed the llvmspirv_pulldown branch from 14c1992 to 0b9b76e Compare March 25, 2026 01:20
@jsji
Copy link
Contributor

jsji commented Mar 25, 2026

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

Labels

disable-lint Skip linter check step and proceed with build jobs

Projects

None yet

Development

Successfully merging this pull request may close these issues.