tsearch.3: Clarify node vs. key and improve markup
Pull in clarifications from Apple's libc: describe the comparison
function's arguments as key pointers, refer to the nodes returned by
tfind() and tsearch() rather than to the "datum", explain how to get a
node's key, note that the action function is called only once for leaf
nodes, and note about how VISIT names don't map to the usual traversal
order nomenclature.
The paragraph about the first member of a node being a pointer to its
key was rewritten, as Apple's wording was not strictly accurate.
Apple's Libc also has a paragraph describing what each traversal order
does, but it is mostly redundant, so it is not included here.
While here, mark up NULL and the VISIT values with .Dv, move the VISIT
typedef into a literal block, and fix mandoc lint warnings.
MFC after: 3 days
[4 lines not shown]
tsearch.3: Fix tdestroy(3) entries in NAME and SYNOPSIS
Add tdestroy to the NAME section, remove a stray opening parenthesis
from its node_free argument in the SYNOPSIS, and small grammar fix in
STANDARDS.
Fixes: b0d4b059cf84 ("tdestroy(3) man page")
MFC after: 3 days
Sponsored by: Klara, Inc.
[VPlan] Erase dead compares of in-loop min/max reduction links. (#243826)
When converting a chain of min/max selects to in-loop reductions, each
select is replaced by a VPReductionRecipe appended to the end of the
block. The compare feeding the next select is skipped, but still uses
the replaced value, so with multiple links in the same block it ends up
using the reduction before its definition, triggering the VPlan
verifier.
The compare is dead once its select is replaced, so erase it together
with the select.
[mlir][Vector] Bail out on rank mismatch in transfer_read unroll (#242293)
Mirror the existing transfer_write guard so UnrollTransferReadPattern
does not rewrite when the source vector rank differs from the target
shape, which previously reused rank-mismatched permutation_map attrs.
Fixes #239698
mount_fusefs(8): accept and ignore the "nempty" option
ntfs-3g mounts with "nonempty" by default and libfuse passes it to
mount_fusefs. getmntopts() treats the leading "no" as negation and
looks up "nempty", which is not in the option table, so the mount fails
with "-o nempty: option not supported". Add the ignore entry that
FreeBSD's mount_fusefs(8) has.
Bug: https://bugs.dragonflybsd.org/issues/3459
[libc] Move the netlink dump code out of if_nameindex (NFC) (#243771)
getifaddrs needs to talk to the kernel the same way as if_nameindex (it
needs to dump interfaces and addresses over a NETLINK_ROUTE socket), so
this patch moves the parts which aren't specific to if_nameindex into
src/__support/net/linux/netlink.h:
- NetlinkSocket, which owns the socket. Its dump function sends the
request and passes the reply messages to a callback, taking care of
NLMSG_DONE and NLMSG_ERROR along the way. If the kernel reports that the
dump was interrupted, it still reads it to the end, and returns
DumpResult::Interrupted so that the caller can retry (up to
MAX_DUMP_ATTEMPTS times, which moves here as well).
- get_nlmsg_header and for_each_rtattr for parsing the messages.
- parse_ifname, which getifaddrs will also use for IFA_LABEL.
The receive buffer handling changes a bit: the stack buffer is now local
to the dump function, and the socket only owns the large buffer, once we
need it. This keeps the socket object small, and makes it easy to keep
using the large buffer for any following dumps (getifaddrs will do two).
[26 lines not shown]
fuse: fix a lost wakeup in the I/O helper
fuse_io_thread() slept first and drained the queue only after waking.
After draining it released helper_spin and called tsleep()
unconditionally. fuse_vop_strategy() queues a bio under helper_spin,
drops the lock and then calls wakeup(), so a wakeup that arrived
between that final spin_unlock() and the interlock taken inside
tsleep() was lost. The helper then slept forever with the bio queued
and the caller hung in biowait().
Hold helper_spin while checking the queue and use ssleep(), which
takes the sleep-queue interlock and drops the spinlock in one step,
so the wakeup cannot be lost.
Bug: https://bugs.dragonflybsd.org/issues/3459
fuse: honor an explicit ftruncate() size
An earlier write extension sets fnp->sizeoverride, which made
fuse_set_attr() keep the old size and ignore an explicit
ftruncate(). Clear the override for FATTR_SIZE setattrs.
Bug: https://bugs.dragonflybsd.org/issues/3459
fuse: zero-fill the tail of a short read
A short FUSE_READ reply copied only the returned bytes into the 4 KiB
BIO buffer, leaving the rest stale, so an mmap read of an unwritten
hole returned old data. Clamp the copy to b_bcount and zero the
remainder.
Bug: https://bugs.dragonflybsd.org/issues/3459
fuse: treat a zero file handle as a valid handle
ntfs-3g returns file handle 0 for regular files. The driver used
fh == 0 as its "no handle" state, so it reopened the file on every
open and skipped FUSE_RELEASE and FUSE_FSYNC. The userspace daemon
then still considered the file open and renamed unlinked files to
.fuse_hidden*.
Add an explicit fh_valid flag to struct fuse_node and use it instead
of the fh value.
Bug: https://bugs.dragonflybsd.org/issues/3459
[Local] Preserve !pcsections when merging instructions (#243076)
combineMetadata dropped !pcsections as unknown metadata, so any merge of
two instructions, such as SimplifyCFG hoisting or sinking common
instructions, lost it.
When an IR transformation merges two instructions into one, the merged
instruction stands for both, so its PC belongs in every section either
requested, with each request's auxiliary data. Add
MDNode::getMergedPCSectionsMetadata, which returns the union of two
!pcsections nodes: the requests (a section name and its auxiliary
tuples) of A, followed by those of B not already in A. Use it in
combineMetadata, including when only J has the metadata, and document
the rule for IR transformations.
Keeping only one of the two nodes, as documented for machine IR, loses
information when the merged instruction stands for distinct requests,
e.g. when the stores of several states of a state machine sink into one
store and each store's auxiliary data identifies its state.
[5 lines not shown]
[libc][NFC] Clean up regex tables, headers, and CMake deps (#243759)
Integer-only baremetal targets cannot rely on floating-point helpers
just to size a hash table, and PIE builds should keep constant lookup
tables in shared read-only memory rather than dirtying copy-on-write
.data.rel.ro pages with dynamic relocations at startup. In addition,
subarchive builds linking regcomp or regexec without regfree miss
operator delete because collect_object_file_deps skips header libraries,
and POSIX requires <regex.h> to export size_t directly.
Switch ExprPool::max_hashtable_nodes() to integer 7/10 arithmetic and
store inline class names in pure .rodata tables behind a [[nodiscard]]
add_posix_class helper, avoiding both 32-byte copies and raw nullable
pointers while shrinking regex_parser.cpp.o by 725 bytes at -O2 and 775
bytes at -Os with zero relocations. Export size_t in regex.yaml, add
direct libc.src.__support.CPP.new dependencies, clear preg before delete
so teardown never exposes a dangling pointer, and tighten internal
assert and static_assert guards.
[4 lines not shown]
[SelectionDAG] Convert soft-promoted f16 to wide integers without a libcall (#235259)
#230779 converts `f16` to the half-width integer type and extends it
when the result of `fp_to_[su]int` must be expanded, but only when `f16`
is legal. When `f16` is soft-promoted (e.g. RISC-V with F but without
Zfh, ARM with VFP but without fullfp16), the conversion still calls
`__fixsfti`, `__fixsfdi`, `__aeabi_f2lz` or their unsigned variants.
Take the same path when `f16` is soft-promoted and `f32` is legal; the
narrower conversion extends the operand to `f32`. The conversion keeps
`f16` as its source type, so that the second expansion of `i128` on
32-bit targets also takes this path. Targets without `f32` keep the
libcall.
Assisted-by: Claude Opus 5.5
[AArch64] Implement latency costs for interleaved loads (#236428)
This is done by moving the existing code for getting the latency of
plain loads out into a separate function and calling that.
[LoopUtils] Check the first outer iteration for co-moving pointer groups
When runtime checks are hoisted out of the outer loop, the range of each
pointer group is widened to cover all iterations of the outer loop. If both
groups of a check advance by the same step in the outer loop, e.g. two rows
of the same image:
```cpp
for (y = 0; y < H; y += 2)
for (x = 0; x < n; x++) {
img[y*S + 3*x] = ...;
img[(y+1)*S + 3*x] = ...;
}
```
the widened ranges overlap as soon as the outer loop runs twice, so the
check always fails and the vector loop never runs.
If all bounds of both groups are affine AddRecs of the outer loop with the
[7 lines not shown]
[flang][MIF] Add lowering for EVENT_QUERY (#237317)
This PR adds lowering support for the `EVENT_QUERY` intrinsic. It is
lowered to a new `mif.event_query` operation, which is then converted to
the corresponding PRIF call.
---------
Co-authored-by: Dan Bonachea <dobonachea at lbl.gov>
[LoopUtils] Factor out the same-step check of runtime check bounds (NFC)
The follow-up change uses four SCEV expressions for this type of change
so it also generalizes it to take an array.
[flang][MIF] Fix STAT= specifier handling in coarray allocation #231248 (#237327)
`ALLOCATE `of a coarray with `STAT=` did not handle the result of
`prif_allocate_coarray `correctly:
The result of the allocation was never checked if STAT is specified, so
the descriptor update the base_addr, the default initialization and
`prif_sync_all `ran even when the allocation failed.
Fixes #231248.
---------
Co-authored-by: Dan Bonachea <dobonachea at lbl.gov>
Co-authored-by: Eugene Epshteyn <eepshteyn at nvidia.com>
[LoongArch] Match BSTRINS when an OR operand is already a BSTRPICK
performANDCombine rewrites (and X, mask) into BSTRPICK, or into
(shl (BSTRPICK X, msb, lsb), lsb) for a shifted mask. The BSTRINS
patterns in performORCombine only match ISD::AND, so they miss an OR
whose AND operand was rewritten before the OR was combined. In the
default order this happens when the operand only becomes an AND after
the OR was combined, e.g. in an expanded funnel shift. With
-combiner-topological-sorting (#83422), which visits operands before
their users, it happens for any OR. The OR is then selected as separate
bstrpick, shift and or instructions.
Before matching, turn such operands back into the AND they came from,
and build the result from the original operands. The pattern conditions
are unchanged.
In the default order this shortens the funnel shift tests. In a sample
of real-world bitcode compiled for loongarch64, 7 functions get shorter
and none longer, e.g. a byte inserted into the top of an i64 and vXi1
[3 lines not shown]
[LoongArch] Add BSTRINS tests with an OR built from a funnel shift (NFC)
Expanding the funnel shift creates the OR first. Its operand only
becomes an AND, which performANDCombine turns into BSTRPICK, after the
OR has been combined, so no BSTRINS pattern matches when the OR is
combined again.
Assisted-by: Claude Code (Claude Opus 5.5)