[libc++][pstl] Add a task scheduler based on std::thread (#237313)
This PR adds a simple task scheduler for PSTL.
With that, `std::execution::par` makes algorithms run in parallel on
non-Apple platforms (Apple platforms keep using `libdispatch`).
The implementation uses only the threading facilities provided by the
C++ Standard and contains no platform-specific code.
This code is intended to be a replaceable implementation detail of
libc++, which is not exported and can only be accessed via the
`std::__pstl::__statpart::__apply()` proxy.
The design prioritises correctness and simplicity over peak performance,
while still performing reasonably for typical usage (comparable to
`dispatch_apply_f()` from GCD).
[SPIRV][Offload] Implement `DynSharedMemory` for L0 (#231160)
This PR implements SLM for Level Zero backend. Every kernel in a module
lowered by the new SPIR-V pass receives a trailing `__local` argument,
including kernels that do not use SLM.
In order to support existing code that uses offload, the PR adds an
additional pass to SPIRV backend. The idea is that the pass is searching
for all extern unsized workgroup arrays and then it converts them to a
global variable that is initialized by an additional kernel argument to
every kernel in the module, including kernels that do not reference the
array.
The pass closes the gap between cuda/hsa and level_zero handling of the
dynamically sized workgroup memory, because level_zero (and openCL) only
support the local memory sized through kernel arguments compared to cuda
which configures it during kernel launch. It was inspired by existing
code in intel's fork of llvm.
[9 lines not shown]
[DAG] SimplifyDemandedVectorElts - add ISD::VECTOR_SHUFFLE_VAR handling (#244921)
Simplify the demanded elements of the mask operand using DemandedElts,
and use the mask's constant range to limit the demanded source elements.
The InstCombine part is in #245249.
Fixes #244310
AI Note: I've used Claude Code to help me understand `SelectionDAG`
concepts and the codebase. The implementation and tests are my own.
[X86] Fix miscompile of srl(xor(y, vecreduce_umax(x)), bw-1) (#244835)
In the signbit reduction fold added in #210281, `X` is initialized to
`N0` as the fallback for a failed `m_Not` match, but `sd_match`
overwrites `X` while trying the `xor` operands, even when the match
fails. If the last operand tried is `vecreduce_umax(x)`, the `xor` is
dropped and the shift is lowered to a `MOVMSK` test of `x`.
Set the fallback only after the match fails.
Fixes #244613
Fixes #244753
Assisted-by: Claude Opus 5.5
[DAGCombiner] Bail out in MatchLoadCombine when no bytes come from load (#244857)
Since #200247, calculateByteProvider returns ConstantZero for bytes
masked by AND with 0. This could make `Loads` empty in MatchLoadCombine
and triggers assertion.
Fix by early return when `Loads` is empty.
Fixes: https://github.com/llvm/llvm-project/issues/244804
Assisted-by: Claude Opus 5.5 <noreply at anthropic.com>
[NFC][ExecutionEngine] Fix calloc argument order in jitprofiling.c (#245189)
calloc takes (nmemb, size); the arguments were swapped. No functional
change, but it silences -Wcalloc-transposed-args on newer compilers.
---------
Co-authored-by: Claude <noreply at anthropic.com>
acpi: Tasks: Ensure taskqueue is running before allowing to drain
In AcpiOsWaitEventsComplete(), fix the test controlling whether to call
taskqueue_drain_all(): That must happen only if threads to process the
taskqueue have been created.
In the initial code, there is a very small window where
'acpi_boot_tasks_nb' could be 0 but some task was concurrently enqueued
(e.g., by an interrupt), leading to a call to taskqueue_drain_all()
which would wait forever in the absence of threads processing the
taskqueue.
Reported by: llm-postcr
Sponsored by: The FreeBSD Foundation
[MLIR][OpenACC] Keep private stores of array reductions on one lane (#245438)
Two fixes in the acc-cg-to-gpu lowering of privatized arrays:
- The walk that finds the acc.private_local behind a memref followed
every operand of the defining op. A memref.reinterpret_cast whose
dynamic sizes come from a different private descriptor was therefore
attributed to that descriptor. Scalar operands (sizes, strides, offsets,
indices) only shape an access, so the walk now follows only the view
source, the base entity of a partial access, or non-scalar operands.
- The per-thread partials of an array reduction are combined across the
accumulate's thread dimensions. Storing the reduction identity is safe
on every lane and initializes each partial. Any other store into a
partial is an update, and it is no longer made active on every thread:
it stays on one lane. Previously such an update ran on every lane, so
its contribution was combined once per lane.
[VPlan] Tighten usecase of findRecipe (NFC) (#236810)
Rename findRecipe to findUserRecursively for clarity, noticing that it
is only ever necessary in epilogue-based reasoning, which falls outside
VPlan modeling. Migrate one user to getSingleUser, and improve code
around remaining two users that do epilogue-based reasoning.
misc/hermes-agent: remove the venv's lib64 symlink
CPython's venv creates lib64 as a symlink to lib on 64-bit. The
plist is built with find -type f / -type d, which never enumerates a
symlinked directory, so check-plist reports the path as orphaned --
and an @dir entry for it fails the type comparison, so it is then
reported as both orphaned and missing.
The symlink is a pure compatibility alias: the wrapper invokes the
venv interpreter directly and the stdlib resolves to lib. Remove it
in do-install alongside the other unneeded venv artifacts.
PR: 300998
[LV] Increase test coverage of FOR-tail-folding (#238318)
Fix missing test coverage for the case when first-order-recurrences have
no in-loop users in the tail-folding case.
Assisted-by: llm
[LLD][ELF] Always finalize a .symtab_shndx section. (#245334)
The SymtabShndxSection::isNeeded depends on the number of Output
Sections. In removeEmptySyntheticSections isNeeded may return true, but
later after adjustOutputSections the number of Output Sections can drop
to below SHN_LORESERVE, meaning that finalizeSynthetic will skip the
SymtabShndxSection::finalize.
This results in a redundant .symtab_shndx section with a sh_link of 0,
which prevents the ELF file from being used by some tools including lld.
Removing the Output Section containing .symtab_shndx after
adjustOutputSections is possible, but requires quite a lot of extra code
that handles edge cases that might happen with a linker script to be
repeated.
For now, always run the finalize when we are going to write the
.symtab_shndx section, which will produce a redundant, but benign extra
section.
fixes: #244372
[GVN] Treat possibly overlapping `lifetime.start` as a clobber in MSSA-path (#245978)
Mirroring 5f88e49e8c24c5b799872b4331d35b5406d3c213, ensure that a
`lifetime.start` that partially or possibly overlaps the memory location
of the load being analyzed is treated as clobber in the MSSA-based walk
as well. A PartialAlias overlap may be handled as a definition in the
future.
[lldb][test] Cache the result of _get_macos_sdk_version (#245955)
_get_macos_sdk_version runs 'xcrun --sdk macosx --show-sdk-version' on
every call. It is called for every decorator evaluation on macOS, so
loading a test file spawns one xcrun process per decorated test method.
For example, loading TestConstStaticIntegralMember.py runs xcrun 30
times, which takes ~0.5s on a good day.
The SDK version can't change during a test run, so cache the result.
assisted-by: claude
[CIR] Fix crashes in the vector constant folders
A constant vector can hold elements that are not integer or
floating-point literals, such as undef and poison. Folding a
`cir.vec.shuffle` with a -1 index produces one. The folders of
`cir.vec.cmp`, `cir.vec.fcmp`, `cir.vec.ternary` and
`cir.vec.shuffle.dynamic` cast every element they evaluate to a literal
and asserted on such a vector. They now leave the operation alone. This
also covers a `cir.vec.ternary` whose condition is a constant vector of
bool, which is still not folded.
Two more assertions in the same folders are fixed the same way:
- The `true` and `false` shortcut of `cir.vec.fcmp` built a constant
from the fixed size of the result type and asserted on a scalable
vector.
- `cir.vec.shuffle.dynamic` indexed past the end of a vector whose
element count is not a power of two.
[4 lines not shown]
NAS-145410 / 28.0.0-BETA.1 / Make `alert.oneshot_replace` reuse existing alerts (#20297)
This is necessary for future work (conflicting paths alerts).
With `reuse`, an instance that matches an existing alert (same class and
key) continues that alert.
Without `reuse`, the method runs `oneshot_delete` with no query, then
`oneshot_create` for every instance. Each step sends its own changes.
NAS-145422 / 28.0.0-BETA.1 / Fix flaky FTP tests (#20306)
Preserving configs from previous test runs made tests unstable as they
became dependent on unrelated and uncontrollable environment.