hwpmc: release a PMC whose ID could not be copied out
If copyout of the newly allocated PMC ID fails, the caller cannot use or
release the PMC. Release it in the kernel.
Reviewed by: mhorne
MFC after: 3 days
Sponsored by: Advanced Micro Devices, Inc.
Differential Revision: https://reviews.freebsd.org/D60562
(cherry picked from commit e5a48c8e0dd026ba953cf401c4dec02f76078aa2)
pmc(8): zero-initialize the event descriptor in stat mode
cmd_pmc_stat allocated the event descriptor with malloc and then set
only some of its fields, so the rest held whatever was on the heap.
Use calloc() instead.
Reviewed by: mhorne
MFC after: 3 days
Sponsored by: AMD
Signed-off-by: Andre Silva <andasilv at amd.com>
Differential Revision: https://reviews.freebsd.org/D59364
(cherry picked from commit a97914284c2e7a7dc330f4d93218e8d7f1e758b2)
[SelectionDAG] Add selectShiftAmountMask and use it for RISC-V (NFC) (#240214)
Many targets drop a shift-amount AND that keeps every bit the shift
reads, each with its own code. This moves RISC-V's version into
`SelectionDAGISel::selectShiftAmountMask` so other targets can share it.
X86 uses it next, for #199697.
The helper looks through one truncate and an AND whose constant, with
known-zero bits, keeps the low Log2(width) bits. It sets the output only
on success. It ignores other users of the AND, so each target decides
that.
RKSimon suggested a TableGen-level fix in #199697. This shares the C++
selector behind target ComplexPatterns instead.
RISC-V output does not change.
Assisted-by: Claude Opus 5.5
pmc(8): zero-initialize the event descriptor in stat mode
cmd_pmc_stat allocated the event descriptor with malloc and then set
only some of its fields, so the rest held whatever was on the heap.
Use calloc() instead.
Reviewed by: mhorne
MFC after: 3 days
Sponsored by: AMD
Signed-off-by: Andre Silva <andasilv at amd.com>
Differential Revision: https://reviews.freebsd.org/D59364
(cherry picked from commit a97914284c2e7a7dc330f4d93218e8d7f1e758b2)
hwpmc: release a PMC whose ID could not be copied out
If copyout of the newly allocated PMC ID fails, the caller cannot use or
release the PMC. Release it in the kernel.
Reviewed by: mhorne
MFC after: 3 days
Sponsored by: Advanced Micro Devices, Inc.
Differential Revision: https://reviews.freebsd.org/D60562
(cherry picked from commit e5a48c8e0dd026ba953cf401c4dec02f76078aa2)
[IRBuilder] Add support for GEP canonicalization (#237255)
This implements support for GEP to ptradd canonicalization in IRBuilder:
Arbitrary GEPs will be converted into a sequence of ptradd
(getelementptr i8) or scaled ptradd (getelementptr [N x i8]).
Because this has substantial impact on existing tests, this is currently
off by default, with only InstCombine opting in via
enableGEPCanonicalization(). InstCombine already canonicalizes itself,
so this only changes a few edge-cases.
The plan is to then opt-in a few more places, then convert the opt-in to
an opt-out, and then remove the opt-out.
mlock_test: use mmap/munmap for unmapped pointer
Instead of hoping that the page after sbrk(0) is unmapped, map a page
with mmap and then munmap it. This won't work with CheriABI and heap
temporal safety, but it's an easy fix for now and works on all
architectures.
Reviewed by: ngie
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D46954
libc: skip telldir_leak test
It uses sbrk to attempt to detect memory leaks in telldir, but we're not
going to export sbrk in the future and this is unreliable for mmap-based
mallocs. It's also a regression test for a specific NetBSD bug.
Reviewed by: ngie
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D46955
comms/wsjtx: Fix build on head
- Homepage has moved to https://wsjtx.github.io/wsjtx/index.html
- Sourceforge and github make no sense code has moved to github remove SF
- files/hamlib.patch files/wsjtx.patch are obsolete in this version
- jt9 needs an executable stack
- bumped PORTREVISION
- petted portlint
[mlir][NFC] Remove includes of headers declaring used traits and interfaces (#240404)
The generated declarations of ops, attributes, types and interfaces now
include the headers declaring the core traits and interfaces they use.
Includes that headers only had for these generated declarations are
therefore redundant. This removes them in MLIR, Flang and ClangIR.
Includes of headers that the hand-written code uses directly are kept,
even when the generated code includes them as well.
Co-authored-by: Claude <noreply at anthropic.com>
[OpenMP] Use device scope for atomic constructs on the device
OpenMP 6.0, 17.8.5 specifies that "The memscope clause determines the
binding thread set for an atomic region. If the memscope clause is not
present, the behavior is as if the memscope clause appeared on the
construct with the device scope-specifier."
Thread the sync scopes through codegen amd also add a release note
because this is changing existing behavior.
Existing behavior was overly cautios for OpenMP 5.2, too, though. The
atomic construct never specified the option of having system-level
scope. This only came with the memscope clause and it's "all"
scope-specifier.
Claude assisted with this patch.
[MLIR][XeGPU] Limit transposed 2D block load height to 16 (#239469)
The hardware supports transposed 2D block loads with height 16 or 32,
but a 32-row tile does not align with the DPAS layout. Limit the
8/16/32-bit transposed block load entries in the uArch table to height
16.
Layout propagation now falls back to inst_data [16, 8] for a transposed
i32 load whose consumer asks for 32 rows, and the peephole optimizer
splits 32-row transposed loads into two 16-row loads.
Add a propagate-layout-inst-data test covering the fallback, and update
the peephole-optimize CHECK lines for the split loads.
assisted-by-claude
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[OpenMP][clang] Apply atomic options to atomic compare
Thread denormal mode, fine-grained memory and remote memory options
through for atomic compare directivs.
Claude assisted with this patch.
[AMDGPU] Remove V_CNDMASK_B64_PSEUDO handling from SIFoldOperands. NFC. (#240324)
This is dead because the pseudo always gets expanded earlier, and broken
because it would have used V_MOV_B32 to move a 64-bit value.
netipsec: Do not leak the SAH when an SA is cloned
key_updateaddresses() gives the clone of an SA a new SAH reference when
the SA index comes from key_newsah() or key_getsah(), but nothing
releases the reference of the old SA: key_delsav() leaves the SAH alone,
because key_unlinksav() normally releases it, and an SA that is replaced
never goes through that. The SAH then stays allocated for good, after
its SAs are flushed and after the vnet is destroyed, as an SADB_UPDATE
with a new address does each time an IKE daemon moves an SA.
The old SA cannot release the reference when it is replaced, since a
sender that still holds it reads its SAH. Release it in key_delsav()
instead. When only the NAT-T config changes, the clone used to take over
the reference of the old SA; take a new one in that case as well, so that
every SA holds its own.
Reviewed by: kib, markj
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D61101
[libc] Apply scheduler attributes on thread creation (#225674)
POSIX specifies that pthread_create should apply the scheduling policy
and parameters given in the attributes object (if PTHREAD_EXPLICIT_SCHED
is set). Linux's clone syscall doesn't support setting scheduling
parameters directly, so we have to apply them from userspace via
sched_setscheduler after the thread is created.
To make sure the thread doesn't start running user code with the wrong
scheduling parameters (and to allow returning an error if
sched_setscheduler fails without leaving a half-running thread), I've
added a startup handshake using the clear_tid futex on the child stack:
- the child waits on the futex if explicit scheduling was requested
- the parent calls setschedparam, and then signals the child to either
continue (running) or abort (exit)
- if the call fails, the child exits immediately, the parent reaps it
via Thread::wait(), and returns the error code to the caller
Assisted-by: Gemini
[OpenMP][clang] Add ompx_fast_fp_atomics and ompx_safe_fp_atomics hints
Add omp_sync_hint_t extensions that override
-f[no-]atomic-ignore-denormal-mode (-m[no-]unsafe-fp-atomics) for a single
atomic construct. The safe hint takes precedence if both are given.
This is an upstreaming/copy-paste of downstream code and release notes.
Claude assisted with this patch.
[libc] Use CheckedPtr/make_unique in the regex code (#238366)
The regex code was written before we had unique_ptr, and so it did all
of its memory management by hand (AllocChecker + new/delete, with
scope_exit guards for the error paths). This replaces that with
make_unique, and stores the results in cpp::unique_ptr members.
Specific changes:
- ExprPool now holds its blocks, byte sets and hash table in
unique_ptr<T[]> members, which means the destructor can be defaulted.
Since unique_ptr does not know the size of the array, the capacity of
each array is now tracked in a separate field (previously it was implied
by the span size).
- make_unique<T[]> value-initializes the array, so the explicit
inline_memset of the hash table is gone.
- ParsedAtomStack and regcomp no longer need scope guards to clean up on
the error paths.
regfree still does a plain delete, as regex_t::__internal is a void
[18 lines not shown]