[Support] Grow bump allocator slabs faster (#243000)
Reduce the default slab growth delay from 128 to 8, retaining 4 KiB
initial slabs.
On CTMark (-march=rva23u64 -O3), median user CPU time drops by
0.11% and peak RSS geomean by 1.96%.
Assisted-by: TRAE CLI (GPT-6)
[AMDGPU] Treat a bitcast between legal types or same-size scalars as free (#238412)
The generic cost model treats a bitcast as free only when both types are
integer types or both are not. AMDGPU keeps integer and floating-point
values in the same registers, so a bitcast between two legal types is a
no-op. A scalar bitcast from i32 to float cost 1, but the vector bitcast
from <2 x i32> to <2 x float> cost 0. The SLP vectorizer counted this
difference as a saving.
A bitcast between two scalars that are legalized to types of the same
size, such as i16 and half without 16-bit instructions, is free as well.
A bitcast that involves a legalized vector, such as a vector of i8,
keeps its cost, because the lanes may need repacking.
Assisted-by: Claude Opus
[SCEV] Look up loop guard rewrites in a single place (NFC). (#242875)
Look up rewrites for expressions once in ::visit, instead of duplicating
code in each visitor.
Currently still limited to set existing set of nodes. I am planning on
extending this to all expressions, but there are a few regressions I
still need to investigate.
PR: https://github.com/llvm/llvm-project/pull/242875
[flang] Remove redundant parse tree walk for NUMERIC_STORAGE_SIZE warning (#241634)
PR #220779 made `ExpressionAnalyzer::Analyze(const parser::Expr &)` walk
the parse tree of an expression every time it returns a saved typed
expression, to repeat the NUMERIC_STORAGE_SIZE check on the names in it.
`IterativelyAnalyzeSubexpressions` analyzes a chain of operations from
the bottom up, and each operation then asks for its already analyzed
operands again, so each node was visited once per enclosing operation.
That is quadratic in the length of the chain: `-fsyntax-only` on an
assignment whose right-hand side adds 60,000 literal constants takes 27
s without this change and 0.4 s with it.
The walk is not needed when semantic analysis reports no error. The
analysis that saved a typed expression has already called `Analyze(const
parser::Name &)` for each name in it, and the warning is added to the
`SemanticsContext` message buffer directly, so contextual message
discarding does not affect it. This change removes the walk and its
visitor.
[5 lines not shown]
[flang] Add SELECT CASE lowering tests for INTEGER(16) ranges and UNSIGNED(16) (#242946)
The test added with the SELECT CASE INTEGER(16) fix (#240149) covers
only point case values. The same lowering path also builds the bounds of
ranges (`#fir.interval`, `#fir.lower`, `#fir.upper`) and the case values
of UNSIGNED(16) selectors, which no lowering test covered.
Add an INTEGER(16) range test to `select-case-statement.f90` and an
UNSIGNED(16) test to `unsigned-ops.f90`, with values on both sides of
`2**64` and of the signed maximum `2**127`. Also fix the indentation of
one `CHECK-LABEL`.
Assisted-by: AI
modstat: allow compat support to fail in tests
v1 and v2 versions of stuct module_stat are now gated by COMPAT_ ifdefs
so allow the otherwise valid query to fail with EINVAL.
Effort: CHERI upstreaming
Reviewed by: markj
Reported by: llm-postcr
Sponsored by: Innovate UK
Fixes: 1ebf46ecb627 ("modstat: don't copyout while holding a lock")
Differential Revision: https://reviews.freebsd.org/D61460
(cherry picked from commit ef726c645300870b6bdf3573079b1f89f3b45c74)
modstat: don't copyout while holding a lock
If a user arranges for a page fault to never be filled (e.g., via a
FUSE file system), this can hold the shared lock forever.
To make this all work, refactor kern_modstat and freebsd32_modstat to
malloc a temporary buffer and fill it before copying it out rather
than doing a bunch of copies.
Add COMPAT_* ifdefs around compat code. The module_stat_v1 code is
really for a.out binaries in practice and thus a bit questionable.
Reviewed by: markj
Reported by: llm-postcr
Sponsored by: Innovate UK
Fixes: 7f8c2056db1e ("modstat: avoid copying from freed memory")
Differential Revision: https://reviews.freebsd.org/D61432
(cherry picked from commit 1ebf46ecb6278e31d7ae029b0f8af3d64e7bc1f9)
modstat: check errno before calling feature_present
feature_present will overwrite errno if COMPAT_FREEBSD13 is not present.
Reported by: llm-postcr
Fixes: ef726c645300 ("modstat: allow compat support to fail in tests")
(cherry picked from commit acd270c8c6542b45e404078b28e1a732106aa76c)
modstat: avoid copying from freed memory
If a module is unloaded after the module is looked up in kern_modstat,
but before one of the copyout's occurs, then the memory being copied
might be freed and reused leading to an information disclosure.
The LLM was particularly concerned about a TOCTOU issue in the length
of the name, but it seems likely that there are issues with all the
copyout's. As such, hold the shared lock throughout.
Reviewed by: markj
Reported by: llm-postcr
MFC after: 3 days
Sponsored by: Innovate UK
Fixes: 9b3851e9e3b1 ("- Lock down the ``module'' structure...")
Differential Revision: https://reviews.freebsd.org/D61398
(cherry picked from commit 7f8c2056db1e39e44c3eda15aa4e53f7fc971cd8)
kern_module.c: add kern_ implementations
In the case of modstat(2) use a cast to access the name member of the
old struct version so the compiler see the right array size. This
addresses a sub-object bounds bug.
Effort: CHERI upstreaming
Sponsored by: DARPA, AFRL, Innovate UK
Pull Request: https://github.com/freebsd/freebsd-src/pull/2284
(cherry picked from commit b96dc2c04fb4f504ad0c752c5d4b074c5bfbf7e0)
[BOLT][AArch64] Fixed signed branch relaxation range checks (#242369)
Currently AArch64 branch relaxation computes absolute distances between
the branch instruction and its target. This is problematic when the
target of the stub is exactly -128MiB away as, the branch will be
relaxed to an ADRP-stub unnecessarily. This patch changes this behaviour
to use signed offsets to check the ranges, including page-relative
offsets for ADRP-stubs.
It should be noted that this patch has been broken off of #229882, based
off of feedback from @labrinea.
Assisted-by: Codex
[flang] Address review comments on chained concatenation fusion
Let concatenation fusion cross operations that only allocate, like the
hlfir.declare of a character literal operand, so that chains ending with a
literal are fused into one buffer. Only operations that may write or free
memory, or whose effects are unknown, now prevent the fusion.
Remove CharacterExprHelper::createConcatenate, which no longer has users.
Add bufferization tests for concatenations whose operands all have a
compile-time length, and for character kind 4.
[flang] Fuse chained character concatenations into one buffer
Lowering creates one binary hlfir.concat per // operator, so a // b // c
was evaluated into an intermediate buffer that was then copied into the
result buffer. Add a canonicalization that folds a single-use hlfir.concat
into its user when no operation in between may modify or release its
operands, and bufferize hlfir.concat with any number of operands. The
buffer is now sized with the hlfir.concat length operand, which can be
computed outside of elemental loops, instead of the sum of the operand
lengths computed in the loop body.
[flang] Track character temporary lifetimes for safe stack placement (#239312)
Scalar hlfir.expr are currently never given hlfir.destroy and are always
lowered as alloca, even when those alloca have dynamic length that pins
them into unstructured control flow loops not surrounded by stack
save/restore, leading to potential stack to grow on each iteration and
to potential stack overflow.
Emit hlfir.destroy for them, add an explicit cleanup region to
hlfir.yield_element, and preserve both through array constructor
lowering, elemental inlining, WHERE lowering and bufferization, which
now allocates these buffers with fir.allocmem. When such an allocation
cannot be hoisted out of the loop, reclaim its stack space with one
stacksave/stackrestore pair per block. Allocation placement then keeps
these temporaries on the stack in every mode (except under
-fdynamic-heap-array which matches the current behavior).
While working on this, it appeared the code inserting stack save/restore
in StackArrays was not properly handling promotion of imbricated
[6 lines not shown]
[mlir][tosa] Enable tosa-to-linalg `allow-non-finites` option by default (#239407)
The TOSA specification seeds reduce_min/max and max_pool with non-finite
values. This commit enables the `allow-non-finites` option by default to
align the default tosa-to-linalg lowering with the TOSA specification.
[SelectionDAG][NFC] Use SDValue in signatures (#242273)
Instead of passing a const SDNode *ptr to the functions in the ISD
namespace in SelectionDAGNodes.h, pass a SDValue.
The reason for this change is that in the vast majority of uses, the
callers work with a SDValue beforehand and retrieve their Node through
the .getNode() member function.
This change should remove indirection.
net-mgmt/ng_ipacct: fails to build on current
ng_ipacct.c:987:28: error: incompatible pointer types passing 'struct inpcbinfo *' to parameter of type 'struct inpcbinfo_ctx *'