[InstCombine] Handle nuw in foldCmpLoadFromIndexedGlobal (#242665)
nuw is safe to handle with any stride and without masking as it means
`Offset + (Index * Stride)` can't wrap.
[IR] Remove unused private type aliases (NFC) (#242614)
AtomicCmpXchgInst::AtomicOrderingBitfieldElement and
AtomicRMWInst::AtomicOrderingBitfieldElement: The last uses were removed
on July 7, 2020 in commit abdd367b200a0bf4176dbdaf200b23f750a35cb0.
TimePassesHandler::PassInvocationID: The last uses were removed on
March 27, 2020 in commit 0125db9ab21de29191e04fe021bb675b146f2645.
Assisted-by: Antigravity
[IPO] Remove unused SampleProfileProber::CurModuleUniqueId (NFC) (#242613)
The last use was removed on April 14, 2025 in commit
8e8d04870dbc3248301534796b4370f75e33f7c0.
Assisted-by: Antigravity
Fix double free when cloning a block with a pending free
dmu_read_l0_bps() captures the source block pointers for a clone
without consulting dnode_block_freed(). A block whose free is recorded
but not yet synced still has a valid on-disk pointer, so the clone
registers a BRT reference to a block about to be returned to the
allocator, and it is freed twice. On a debug build this trips the
metaslab double-free verifier; on a release build the space map is
silently corrupted.
Check for a pending free and return EAGAIN, as dbuf_read_hole() already
does for buffered reads. zfs_clone_range() waits a TXG and retries, by
which point the block reads as a hole.
Two cases need more than the plain check. A hole has nothing to free,
so guard with !BP_IS_HOLE(bp), otherwise a hole inside a pending free
range fails a FICLONE that master cloned. When the head dirty record
already overrode the BP, only frees after the override count against
it, so use dnode_block_freed_after(); dbuf_free_range() leaves the
[19 lines not shown]
dbuf: restore BP_IS_HOLE() recheck after dnode_block_freed()
Commit 79cf54582 ("Fix reads for blocks freed after being cloned")
reworked the level-0 check in dbuf_read_hole() and dropped the
BP_IS_HOLE() recheck that followed dnode_block_freed(), together with
the comment explaining it. That recheck was not about overrides: it
closes a race with dnode_sync().
dnode_sync_free_ranges() drops dn_mtx, clears the bps through
dnode_sync_free_range_impl() -> free_blocks(), then retakes dn_mtx and
removes the range from dn_free_ranges. For blkptrs held in the dnode
(dn_nlevels == 1), free_blocks() writes the bp without the parent's
db_rwlock, so holding that lock in dbuf_read() does not serialize
against it. A reader that saw a non-hole bp, then waited on dn_mtx in
dnode_block_freed() until the range was removed, gets "not freed" while
the bp it is about to copy is already a hole (with HOLE_BIRTH, lsize
and birth preserved). dbuf_read_impl() then hands that hole to
arc_read(): no child I/O is issued, checksum verification fails with
EINVAL, and without ZIO_FLAG_CANFAIL the pool is suspended.
[26 lines not shown]
Fix direct reads of blocks pending free
Direct reads only check the on-disk block pointer for holes, so they
can read stale data after a block has been freed but before the free
has synced. Share buffered read hole detection with direct reads to
honor pending frees as well.
Keep cached data ahead of hole detection and preserve the transaction
ordering of block clone and direct write overrides. Retain the block
pointer recheck after dnode_block_freed() for concurrent syncing.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Wale Zhang <wale.zhang.ftd at gmail.com>
Closes #19633
Approved by: re (cperciva)
Approved by: kevans (mentor)
(cherry picked from commit 924b8c89c04e324649855b05986f686b58ca4cb9)
(cherry picked from commit afc7fc2abe807780e6f9cba96ab73105ebd2a07f)
amd64/vmm: Don't advertise AMD PerfMonV2 or performance counters
vmm does not handle CPUID leaf 0x80000022, so a FreeBSD guest on a
Family 19h or later host panics on "kldload hwpmc", which trusts the
PerfMonV2 bit and writes AMD_PMC_GLOBAL_CTL.
Approved by: re (cperciva)
Tested by: Osvaldo Janeri Filho <ojanerif at amd.com>
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Reviewed by: markj, kib
Differential Revision: https://reviews.freebsd.org/D61141
(cherry picked from commit 8fb539b081dbfe3e93e607a5d4d36184c53c8aaf)
(cherry picked from commit ade540f274d52366b46da2898b2c264b4e89883a)
DAG: Allow narrowing uint_to_fp source to the zext source type
The narrowing fold skipped uint_to_fp (zext x) when the narrow type
matched x, to avoid undoing a target combine that widened the source.
AMDGPU was the target doing this, and stopped in 50d1a75d978c. This
prevented the fold in the most direct case, so uitofp (zext i32 to i64)
was expanded as a 64-bit conversion. This also hit with topological
DAG combine ordering, where zext i16 -> i64 is first rewritten to a
zext from i32.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
AMDGPU: Add more uitofp of zext from i32 tests
These currently get the full i64 conversion expansion.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DAG: Look through fp_extend/fp_round when folding bitcast of fcopysign (#242587)
visitFCOPYSIGN strips these from the sign operand, but the bitcast may
be visited first, leaving the conversion live in the integer form. Strip it in
the fold too, so the result does not depend on visitation order.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
UPDATING: note login-name validation in pw(8)/pwd_mkdb(8)
An existing master.passwd with a login name containing a now-disallowed
charater will make pwd_mkdb(8) fail until the name is fixed, which blocks
passwd(1), chpass(1) and pw(8). Warn users to audit their accounts
befroe updating.
Reviewed by: bcr
Differential Revision: https://reviews.freebsd.org/D61507
RuntimeLibcalls: Mark noreturn and pure helper libcalls
Mark the functions which never return as noreturn. Add some nounwind
and cold, mostly following inferLibFuncAttributes. Mark
misc. functions as pure.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add attributes inferLibFuncAttributes gives libcalls
Remove more differences with the attributes the InferFunctionAttrs
pass would add to the declared libcalls.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Make the AEABI memory functions distinct libcalls
__aeabi_memcpy, __aeabi_memmove and __aeabi_memset were
implementations of MEMCPY, MEMMOVE and MEMSET but did not have the
same signature. These return void instead of returning the destination
argument. Additionally __aeabi_memset takes its size before its
value. Add distinct Libcalls since these are not the same.
ARM relied on MEMCPY resolving to __aeabi_memcpy for the memcpy calls
it did not specialize, such as unaligned and minsize copies. Select
the AEABI functions in ARM lowering for those as well.
To keep these as tail calls, the EmitTargetCode* methods now take an
in/out IsTailCall like CallLoweringInfo. As a side effect this allows
all the targets emitting calls for the specialized code emit tail
calls, including the __aeabi functions.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add attributes to memcpy, memmove and memset
Annotate memcpy, memmove and memset with the attributes
inferLibFuncAttributes gives them. Also handle the __aeabi variants,
which aren't exactly the same.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
DAG: Use shl of any_extend to place the sign bit when folding bitcast of fcopysign (#242581)
When the sign operand is narrower than the result, only its sign bit is
used. Move it into place with a shift of an any_extend instead of a
sign_extend.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Mips: Use inline register class syntax in MIR tests (#242451)
Also clean up unnecessary registers sections.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CodeGen] Declare -mtune and --save-stats in TableGen (#242586)
Move them into CodeGenToolOptions and remove codegen::RegisterMTuneFlag
and codegen::RegisterSaveStatsFlag. opt and llc use them while other
tools passing codegen::getToolOptions now accept and ignore them.
LLM-aided
[libc][math] Add integer-only implementation for exp10f. (#237009)
- Add `src/__support/math/exp10f_integer_eval.h` using the shared
`exp2_eval` and fixed-point utilities from `exp2f_integer_utils.h`.
- Select `exp10f_integer_eval` in `src/__support/math/exp10f.h` when
`!defined(LIBC_TARGET_CPU_HAS_FPU_DOUBLE) &&
defined(LIBC_MATH_HAS_ASSUME_ROUND_NEAREST_ONLY) &&
defined(LIBC_MATH_HAS_NO_EXCEPT) && defined(LIBC_MATH_HAS_NO_ERRNO)`.
- Expose `exp10f` with explicit rounding mode parameter under
`LIBC_NAMESPACE::shared::static_rounding`.
- Add smoke, unit, exhaustive, and shared math test coverage for
`exp10f_integer_eval` and `static_rounding::exp10f`.
Assisted-by: Gemini is used for code size analysis, performance tuning,
and test refactoring.
kernel - Fix in6_pcbsetlport() panic
* An assertion is issued after lport is modulo-incremented but
before checking to see if the loop has exhausted.
This can result in a field overflow causing the assertion to
fail.
* Fix by moving the assertion to the correct place.