[libc++][ci] Build the libstdc++ benchmarks with TBB and enable PSTL in this config (#243119)
This PR adds the include and the library paths to TBB when building
benchmarks against `libstdc++`, such that its PSTL implementation can
run in parallel.
[libc++][pstl] Add benchmarks for parallel std::transform_inclusive_scan (#241312)
This PR adds a few benchmarks for the parallel scanning operations, in
this case particularly `std::transform_inclusive_scan()`.
[libc++][pstl] Add a parallel implementation of std::unique_copy (#247149)
This PR refactors the existing parallel implementation of `copy_if` into
a more generic `__parallel_flagged_copy`.
The refactored implementation takes an abstract "flagger" that populates
the bit set, instead of explicitly requiring a unary predicate.
With this change, the algorithm can accommodate both `copy_if` and
`unique_copy`, such that these functions basically differ only in the
flagger they pass into `__parallel_flagged_copy`.
[libc++][pstl] Support platforms that have threads but no lock-free types (#248081)
Previously the code in PSTL demanded lock-free properties from some
atomics as a defensive measure, but after some discussions it was
decided that we don't want to make this decision for the user.
As a drive-by this patch reduces the number of preprocessor branches in
`statpart.cpp` and removes the dummy serial implementation of
`__apply()` from it, since this function shouldn't be called when the
platform has no support for threading.
[lldb] Don't skip a frame after an interrupted frame fetch (#248090)
`StackFrameList::FetchFramesUpTo()` increments
`m_concrete_frames_fetched` after taking the index to be fetched. If the
fetch is interrupted, the idx is not restored, so the frame is never
added.
`TestInterruptBacktrace` is flaky on ARM64 Windows because of this.
This patch restores the index.
[AMDGPU] Implement builtin and intrinsic for s_wait_idle (#244238)
`s_wait_idle` is available since gfx10, but has so far not been exposed
in intrinsics. It waits for all dependency and memory counters to reach
0, similar to `s_waitcnt 0` on older architectures.
This can be useful for microbenchmarks, to ensure that only intended
operations are included in time measurements. **It should not be used
for attempts to circumvent the memory model.** There are alternatives
for "synchronization without cache invalidate/writeback" patterns that
are designed for this purpose.
Disclaimer: The implementation was mostly done by AI; I've reviewed it
and checked that it matches existing examples for similar builtins and
intrinsics.
Fixes: LCOMPILER-3256
Assisted-by: AI Coding Agent
[analyzer] Fix crashes on unusual macros in tryExpandAsInteger (#248108)
tryExpandAsInteger crashed on empty macro definitions because of an
unchecked .back() call, and an assertion fired when the value of a macro
did not fit into int64_t. Values wider than an int that still fit into
int64_t were silently truncated. Return std::nullopt in these cases.
Values above INT_MAX that fit into the bits of the target's int are
still converted to it, because DragonFly BSD defines AT_FDCWD as
0xFFFAFDCD.
Fixes #246164.
Assisted-by: Claude Code
[LoongArch] Lower splat of variable-index extract to [x]vreplve (#244542)
Lower a splat of a variable-index extract_vector_elt to [x]vreplve. For
256-bit vectors, each 128-bit lane must splat the element at the same
position within the lane, which is the per-lane semantics of xvreplve.
Also, [x]vreplve only uses the low bits of the index, so drop redundant
masking of it.
Assisted-By: LLM
[LoongArch][NFC] Add tests for splat of variable-index extract (#244541)
Add tests for splatting a vector element selected by a variable index,
for splatting such elements within each 128-bit lane, and for [x]vreplve
intrinsics with a masked index.
Assisted-By: LLM
[VPlan] Replace reassociateHeaderMask with a combine (#247946)
At the time reassociateHeaderMask was added, header masks weren't region
values and combineRecipes didn't have a worklist. Now that we have both
we can avoid the separate pass and move it into combineRecipes.
This also improves codegen on RISC-V because we now reassociate on every
call to combineRecipes, and after other combines have been applied.
[AMDGPU] Skip 32-bit addresses in SADDR fallback
Since #245220, SelectGlobalSAddr also accepts 32-bit (AS6) addresses.
The out-of-range offset fallback walked such an address before it was
extended, so a divergent AS6 load with a large constant failed with
"illegal VGPR to SGPR copy", and a wrapping 32-bit add could have been
split. Skip 32-bit addresses there and add a test.
Rename isUniformInVGPRs to isProducedInVGPRs: it asks where a uniform
value lives, not whether it is uniform. Update the async LDS tests for
the new s_wait_xcnt and the multicast mask clamp.
[LoongArch] Remove redundant divisor guards from vector div/rem (#244485)
The Rust portable implementations of the [x]vdiv/[x]vmod intrinsics
guard the divisor against zero and signed overflow, e.g.
```
%bz = icmp eq %b, 0
%guard = or %bz, (and (icmp eq %a, MIN), (icmp eq %b, -1))
%d = select %guard, splat (1), %b
%q = sdiv %a, %d
%r = select %bz, splat (0), %q
```
The hardware already returns 0 for x / 0 and x % 0, MIN for MIN / -1 and
0 for MIN % -1, so the guards are redundant. Fold them into new
VDIV/VDIV_U/VMOD/VMOD_U nodes to emit a single [x]vdiv/[x]vmod.
Assisted-by: LLM
[LoongArch][NFC] Add tests for vector div/rem with guarded divisors (#244483)
Add tests for vector div/rem whose divisor is guarded against zero and
signed overflow, as produced by portable implementations of the
[x]vdiv/[x]vmod intrinsics.
Assisted-by: LLM
[libc++][docs] Add WG21 issues and papers voted in 2026-11 Buzios (#247586)
Notably, there are some papers addressing C++26 NB ballot comments, so
presumably they should be treated as C++26 papers. Remaining papers and
LWG issues are considered belonging to C++29.
For LWG4612 which is not yet adopted, GH issue is created and then
closed for the convention.
[cmake][lldb] Use Python3_SABI_LIBRARY_DIRS (#246347)
CMake now requires 3.31.
Clarified the comment to mention where the pragma comes from since it's now in the LLVM codebase.
Restructured the code slightly to make the dynamic plugin path use the correct library directory variable. Ditto for the other.
[AArch64][MachineOutliner] Handle async CFI for outlined calls
When calling outlined functions from a function that needs asynchronous
unwind information, we need to add extra CFI instructions at the call
site in some cases, depending on how LR is saved in the caller. We have
the following cases:
1. LR doesn't need saving at the call site. In this case we don't need
any extra CFI instructions.
2. LR is saved in a free register. In this case we need to add
`.cfi_register w30, wN` and `.cfi_restore w30` around the function
call. This will make sure that an unwinder can recover the correct LR
value.
3. LR is saved to the stack. Since this case modifies the value of SP,
and thus potentially the CFA, we disallow it entirely with
asynchronous unwind info. We could probably allow some special cases,
e.g. when the function doesn't use FP, but then we would have to
reimplement complex functionality from `AArch64FrameLowering`.
[AArch64][MachineOutliner] Emit async CFI in outlined functions
When requesting asynchronous unwind info, CFI instructions are now added
to the epilogue of outlined functions. The prologue CFI is also modified
to make it compatible with asynchronous unwinding.
[AArch64] Add flag to enable async unwind info for minsize functions (#236832)
Asynchronous unwind information is currently disabled for functions with
the `minsize` attribute, because some features used for such functions
(function outlining, homogeneous prologue/epilogue) don't handle
asynchronous unwind info at the moment.
The new flag, `-aarch64-enable-async-unwind-for-minsize`, overrides the
default behaviour, and enables async unwind info generation for
`minsize` functions, assuming that the function also has the
`uwtable(async)` attribute.
The new flag will allow us to incrementally improve and test function
outlining and homogeneous prologue/epilogue to support asynchronous
unwind information.
[LoongArch] Select [x]vbitset/[x]vbitrev for or/xor of bitcasted shl(splat(1), y) (#241239)
When the shift of splat(1) is performed in a narrower element type than
the or/xor, e.g.
```llvm
%s = shl <8 x i16> splat (i16 1), %y
%m = bitcast <8 x i16> %s to <2 x i64>
%r = xor <2 x i64> %x, %m
```
the existing [x]vbitset.{b/h/w} and [x]vbitrev.{b/h/w} patterns fail to
match and we emit vrepli + vsll + vor.v/vxor.v.
Fold OP(bitcast(shl(splat(1), y)), x) into
bitcast(OP(shl(splat(1), y), bitcast(x))) for OP in {or, xor} so that
the operation is done in the shift's element type and selected as a
single [x]vbitset or [x]vbitrev.
Assisted-By: LLM