[libunwind] Clear the signal frame state after compact unwind steps (#232823)
`_isSignalFrame` was only updated by DWARF steps. After stepping out of a
signal frame (always DWARF, since compact unwind can't encode them; see
#186458), compact steps left it set, so later return addresses were
treated as exact IPs. Besides misreporting `unw_is_signal_frame`, this
looks up the wrong function's unwind info when a return address is the
start of the next function (e.g. if there was a noreturn call at the end
of a function). Clear the state on compact steps.
Assisted-by: Claude Opus 5.5
[SelectionDAG] Add extension attributes in more places. (#232128)
- ubsantrap argument extension.
- atomic memset value argument extension.
- atomic memcopy/memmove/memset Size args passed as size_t.
Co-authored with IBM Bob.
[ThinLTO] Record prevailing GUIDs by linker symbol name (#226911)
`LTO::addThinLTO` updates `GlobalResolutions` using the IR name from a
summary, but that map is keyed by mangled linker symbol names. On
Mach-O, the IR name `_foo` can therefore match the resolution for `foo`
(whose linker name is `_foo`). This assigns `_foo`'s GUID to `foo` and
can incorrectly internalize `foo` even when another module references
it, producing an undefined-symbol error.
Move the GUID assignment into the symbol loop, where `Sym.getName()`
identifies the correct resolution and the GUID has already been obtained
using `Sym.getIRName()`. Preserve the prevailing-definition check and
the existing fallback for bitcode without a GUID table.
This fixes a regression introduced by
39dcb0ff91b312bb269334168d5e32be78b60417 (#201849). It surfaced when
linking mimalloc 3.5.3 into a PGO/ThinLTO build of LLVM on macOS. The
standalone reproducer below needs only Clang, LLD, and the macOS SDK.
[42 lines not shown]
[LV] Don't emit duplicate negative stride runtime checks (#233132)
This speeds up x264 by 2.15% on RISC-V by avoiding a duplicate hoisted
runtime check.
When hoisting runtime checks we need to check that any strides are non
negative. But for a loop like
```c
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
dst[(i * stride1) + j] = src1[(i * stride2) + j] + src2[(i * stride2) + j];
```
We have the pairs [dst, src1] and [dst, src2]. Both pairs end up
checking that stride1 and stride2 are non-negative in IsConflict, and
because there's other values between the two checks in the chain of ors
InstCombine can't deduplicate it. This PR deduplicates the stride
checks.
[90 lines not shown]
vdev_removal: don't remove a mirror with a child still resilvering
The top-level DTLs of a mirror only contain ranges that are missing
from all of its children, so spa_vdev_remove_top_check() accepted the
removal of a mirror while one child was still waiting to be resilvered
or rebuilt (e.g. right after 'zpool attach' or 'zpool attach -s', or
after onlining a stale device with the resilver deferred or suspended).
The removal copy does not honour the children's DTLs: when the
destination is not a mirror the read is load-balanced across children
by vdev_mirror_child_select() with io_txg == 0, and for mirror
destinations the source child is chosen by index. The copied data is
not checksum-verified, so stale data from the resilvering child was
silently written to the new location, and once the removal completed
the only good copy was gone, resulting in permanent data errors.
Refuse the removal with EBUSY while any writeable child has a
non-empty DTL_MISSING (vdev_resilver_needed()), as is already done for
'zpool split'. This also covers a sequential rebuild, which keeps the
[14 lines not shown]
ZTS: test removing a mirror while a child is resilvering
Add removal_with_resilver, which attaches a disk to a single-disk
top-level vdev with scan progress suspended, so the new mirror child is
still waiting to be resilvered, and checks that 'zpool remove' of that
mirror is refused. It then lets the resilver finish, removes the mirror
and verifies the pool has no data errors. It does this for a healing
resilver and for a sequential rebuild ('zpool attach -s').
This currently fails: the removal is accepted while the new child still
holds no data, and the removal copy can read the stale child, losing
data permanently. The fix follows in the next commit.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Will Rouesnel <wrouesnel at wrouesnel.com>
Closes #19278
[OpenMP] Fix construct context at TARGET and repeated-construct subsets
OMPContext has two bugs in how construct selectors are matched. Both can
select the wrong variant:
- The construct context should start at the innermost enclosing TARGET,
but Clang and Flang add every enclosing construct. Inside a TARGET
region nested in a PARALLEL, construct={parallel} matched the outer
PARALLEL. OMPContext::addTrait now drops the constructs recorded before
a target trait.
- A selector that only repeats a construct, such as
construct={parallel do, parallel} over construct={parallel do}, adds no
property. isStrictSubset required fewer properties, so a score tie
between the two fell back to clause order. A shorter ordered construct
sequence now also makes a strict subset. If the shorter selector has a
user condition, or an ISA name the longer one lacks, the tie still falls
back to clause order, since different conditions or ISA names share one
property.
[9 lines not shown]
[libc] Enable baremetal Armv7-M pre-merge tests
The tests are run using QEMU system emulation on AArch64 GitHub runners.
No strong reason to use AArch64 instead of x86_64 as it is via emulation
anyway. But AArch64 runners are cheaper, so that might prove beneficial.
[libc] Application and testing support in baremetal Armv7-M CMake cache file
This patch adds support for linking and running applications, including
tests, targeting baremetal Armv7-M to the corresponding CMake cache
file.
The cache file takes into consideration if compiler-rt is enabled or
not. If it is, then linking applications is possible, and the relevant
CMake variables are set to enable test runs. If not, then only the libc
build is possible and enabled.
Particular libc configuration options, memory mappings, and QEMU options
are based on what Arm Toolchain for Embedded uses in its fully working
downstream testing.
[libc] Add qemu-system-arm to libc Dockerfile for Arm baremetal testing
This patch adds `qemu-system-arm` to the packages installed into the
Docker image so that we can run Arm baremetal tests.
It is only installed on the AArch64 platforms because we intend to run
the tests on AArch64 GitHub runners. Therefore there is no need to
install on x86_64.
[Clang][OpenMP] Convert `flatten` floating-point trip-count to integers (#229458)
Fixes #225753
Solution: The compiler now turns that trip count into an integer before
it builds the flattened loop. The width follows the existing rule. If
the loop variable is an integer, the new count keeps that variable's
signedness, so a `long` loop with a `double` count stays signed.
If the conversion fails, `flatten` returns an error instead of aborting.
vdev_removal: don't hold ms_lock while cancel loads a space map
spa_vdev_remove_cancel_sync() is the last place that holds a
metaslab's ms_lock across space_map_load(). It can't deadlock the way
spa_vdev_remove_thread() and vdev_rebuild_thread() could: it runs as a
sync task, after every write of the syncing txg has completed, so no
write interrupt thread can be waiting there to free a block, and
nothing new is allocated on a vdev that is being removed.
Drop ms_lock around the read here as well, so that ms_lock is never
held across space map I/O, and ASSERT it as at the other call sites.
Without this the ASSERT fails in removal_cancel and
removal_with_errors, which cancel a removal. In syncing context
nothing else changes the metaslab's space map, ms_freeing or unflushed
trees while the lock is dropped.
Reviewed-by: Matthew Ahrens <matt at mahrens.org>
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Will Rouesnel <wrouesnel at wrouesnel.com>
Closes #19332
[libc] Add floating-point bitwise operations to FPUtil.
Add `fp_and`, `fp_or`, `fp_xor`, `fp_andnot`, and `fp_not` to
`src/__support/FPUtil/fp_bitwise.h` to perform bitwise operations on
floating-point values directly in FP/SIMD registers when SSE2 or AArch64 NEON
is available, avoiding GPR round-trips.
vdev_rebuild: don't hold ms_lock while loading a space map
vdev_rebuild_thread() reads each metaslab's space map while it holds
ms_sync_lock and ms_lock. When the read hits an error, ZFS reads
another copy and then issues repair writes as children of the read, so
the read only completes after those writes complete in a write
interrupt taskq. If a thread of that taskq is meanwhile freeing a
block in the same metaslab, it waits for ms_lock (metaslab_free() from
zio_free_sync() on all builds, and metaslab_check_free() on debug
builds), and nothing moves. With two CPUs the write interrupt taskq
has a single thread, so this hangs the pool. It is the same deadlock
as in device removal (previous commit).
It was reproduced with a test that is not included here, the device
removal reproducer adapted to a sequential resilver: a single write
interrupt thread (zio_taskq_write), metadata on two special vdevs with
read errors injected into one, a debug-only delay before each space
map read of the rebuild, and blocks in that metaslab overwritten and
synced during each delay, after "zpool attach -s" to the normal vdev.
[16 lines not shown]
vdev_removal: don't hold ms_lock while loading a space map
spa_vdev_remove_thread() reads each metaslab's space map while it holds
ms_sync_lock and ms_lock. When the read hits an error, the mirror reads
another child and then issues repair writes as children of the read, so
the read only completes after those writes complete in a write
interrupt taskq. If a thread of that taskq is meanwhile freeing a
block in the same metaslab, it waits for ms_lock (metaslab_check_free()
on debug builds, metaslab_free() through free_from_removing_vdev() on
all builds), and nothing moves. With two CPUs the write interrupt
taskq has a single thread, so this hangs the pool. 676b7ef10 fixed the
same deadlock for svr_lock.
ZTS removal_with_errors injects read errors on one side of the mirror
it removes, and hung like this on the 2-CPU CI runners: z_wr_int
blocked in metaslab_check_free_impl(), spa_vdev_remove in zio_wait()
under space_map_load(), and txg_sync and "zpool remove" waiting for
them, until the job timed out.
[21 lines not shown]
Legacy LTO: Set library options in LLVMContext (#233146)
llvm-lto and libLTO parse -mllvm style options with
cl::ParseCommandLineOptions, which sets library options in T::Global.
Since #233044, the LLVMContexts that LTOCodeGenerator and
ThinLTOCodeGenerator use read the defaults instead, so passes ignore
options like -vectorize-loops.
Parse the options into a cl::LibraryOptionsContext and switch to
cl::parseCommandLineOptions.
LLM-aided
[ELF] --icf: Fix crash on out-of-range merge section addend (#233295)
`getSymVA` validates a relocation referencing a merge section's
STT_SECTION symbol (#188677). ICF runs before getSymVA and its
`constantEq` calls getSectionPiece unchecked, leading to an invalid
`pieces[idx-1]` access in MergeInputSection::getParentOffset for an
out-of-range addend.
Treat such a reference (not seemed to generated by compilers) as unequal
to any other to fix the crash.
[AArch64][TTI] Cost the Ands of a NEON bit select as free
Or(And(M, A), And(Not(M), B)) selects to a single BSL/BIT/BIF. Charge the
Or and treat the single-use Ands in its block as free, using the matcher
shared with operand sinking.
[CIR][Docs] Remove enabling MLIR explicitly in projects list (#233476)
Remove enabling MLIR explicitly in the `DLLVM_ENABLE_PROJECTS` when the
goal is to build ClangIR, because after #221739, it will be enabled
implicitly and linked with what ClangIR needs only.
[lldb][SymStore] Abort cached file stream if request failed (#232848)
A continuation of #232038 to fix a crash when an HTTP request fails with
some data already received. The fix here is to abort the cached file
stream if the request fails.
The test uses the same responder as in the debuginfod test. I also
checked that it fails if we don't abort.
ZTS: run mmap_sync_001_pos only from the Linux runfile
mmap_sync_001_pos appears in both common.run and linux.run, so the
default Linux suite executes it twice. The test requires Linux VM
tunables in /proc/sys/vm and skips other platforms.
Keep its registration in linux.run and remove the common.run entry.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Kamil Monicz <kamil at monicz.dev>
Closes #19453
[Clang] Fix preserved C++ field indices (#226790)
Since 048493f88, preserved field accesses have used source field
ordinals
as debug-info indices. 4754814c5 accounted for omitted unnamed
bitfields,
but C++ debug info also contains bases, static members and vtable
pointers. For "struct S : Base { int x, y; }", the index for y therefore
identifies x. BPF CO-RE uses that index to select the field and its
offset.
Record each field's index while emitting its debug info and return it
with the record type. Complete the record and its bases for these
accesses: limited and constructor debug modes can otherwise leave only
forward declarations, without the layout needed for relocation.
Assisted-by: OpenAI Codex