Fix out-of-bound regression at vdev_mirror_io_done()
This is a follow up fix after commit f0b335239 where the
regression was introduced, mm->mm_child[last_good_copy].mc_abd
referencing (line 930) without last_good_copy >= 0 guarding.
Solution: best_abd already has the needed value at this point,
which is also guarded, use it instead.
Also, drop duplicate 'redundancy_mirror' test entry from
tests/runfiles/common.run, another regression in the same commit.
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Signed-off-by: Andriy Tkachuk <atkachuk at wasabi.com>
Co-authored-by: xfcyhuang <xfcyhuang at aliyun.com>
Closes #20139
ELFObjectWriter: Diagnose SubSym in PC-relative operands (#249003)
PC-relative fixups should not have subtrahend and `call undef - 0b`
currently hits `assert(!IsPCRel && "should have been folded").`
Without assertions, the call targets `undef + 2`, measured from the
fixup rather than from the instruction. GNU Assembler behavior is
inconsistent: it rejects `jmp undef - .` but accepts `call undef - .`.
Report an error instead.
```
# llvm-mc -filetype=obj -triple=x86_64 a.s
0:
nop
call undef - 0b # error: unsupported symbol difference in PC-relative operand
jmp undef - . # error: unsupported symbol difference in PC-relative operand
```
ng_netflow: re-derive pointers after M_CHECK
M_CHECK calls m_pullup, which may reallocate. Three pointers were stale:
evh in the VLAN path and ip in the IP-options path.
Reviewed by: markj, glebius
Differential Revision: https://reviews.freebsd.org/D62429
[lldb][bazel] Pass the liblldb exports file as a version script (#248423)
`gen_exports_file_linux` already writes the exports in version-script
syntax (`{ global: ...; };`), but the linkopt hands it to the linker as
`--export-dynamic-symbol-list`. lld and GNU ld 2.35+ accept that option,
gold does not, and gold is what Bazel's autoconfigured GCC toolchain
picks when it is installed, so a GCC build of liblldb fails with
"ld.gold: --export-dynamic-symbol-list=...: unknown option". Pass the
file as `--version-script` instead, which is what the CMake build does
through `add_llvm_symbol_exports`, and which lld, ld.bfd and gold all
accept. With no `local:` clause the exported symbol set is unchanged.
tests: add ZTS tests for Linux quotactl_fd(2)
Add userquota_015_pos.ksh and userquota_015_neg.ksh to verify ZFS user,
group, and project quotas, space and inode limits, and default quotas
via quotactl_fd(2), plus rejection of unsupported operations and
read-only targets.
Use quota(1) and setquota(8) when quota-tools >= 4.10 is available
(patching tmpfs->zfs for 4.10-4.11). On quota-tools <= 4.09, verify
the expected error text and fall back to the quotactl_fd test helper
(tests/zfs-tests/cmd/quotactl_fd.c) on kernels >= 5.14.
Install the quota package in Linux CI VMs and register the tests in
tests/zfs-tests/tests/Makefile.am, tests/zfs-tests/cmd/Makefile.am,
and tests/runfiles/common.run.
Assisted-by: Antigravity
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
[2 lines not shown]
Linux: implement quotactl_ops for quota control
Implement struct quotactl_ops (sb->s_qcop) on Linux so standard VFS
quota calls such as quotactl_fd(2) query and modify ZFS user, group,
and project quotas.
This allows quota-aware applications like Samba to inspect user and
group quotas directly via standard kernel interfaces without spawning
external helpers or requiring specialized out-of-tree modules.
Assisted-by: Antigravity
Reviewed-by: Brian Behlendorf <behlendorf1 at llnl.gov>
Reviewed-by: Tony Hutter <hutter2 at llnl.gov>
Signed-off-by: Ananda Bhattacharya <a3217055 at gmail.com>
Closes #19658
[HLSL] Add support for SV_CullDistance (#247321)
Note for SPIR-V: as in DXC, all cull distances of an input or output are
combined into one CullDistance built-in float array. Each semantic index
starts at an offset into the array, in increasing semantic index order.
This is what is responsible for the larger code change in
`CGHLSLRuntime`. Please see `CGHLSLRuntime.h` first for an overview of
what happens here.
The CullDistance capability is also made available for Vulkan as
required.
Resolves: https://github.com/llvm/llvm-project/issues/136973
Assisted by: Claude Opus 5.5 and Gemini Neon
[lldb] Find threads by ID in constant time (#247331)
ThreadList now keeps a map from each thread ID to the index of the first thread with that ID. FindThreadByID builds the map when it is empty, and every change to the list clears it. AddThread, AddThreadSortedByIndexID and InsertThread become virtual in ThreadCollection, so that ThreadList's overrides also clear the map when a thread is added through a ThreadCollection reference. The map assumes that a thread's ID doesn't change while the thread is in a list, which holds for every caller of Thread::SetID. When two threads share an ID, the first one is still returned.
---------
Co-authored-by: Bar Soloveychik <barsolo at fb.com>
[lldb] Cache missing language runtimes (#247765)
`Process::GetLanguageRuntime` searched every language runtime plugin
again each time it was asked for a language whose runtime it hadn't
found. The unwinder asks for every language's runtime on every frame
(`LanguageRuntime::GetRuntimeUnwindPlan`), and a search can scan every
module: the GNUstep Objective-C runtime looks through all of them for
`libobjc.so`.
When I was testing on a core file of an NVIDIA GPU process with 8,116
modules and 85,088 threads, `bt all` took 139 seconds. with this change
it now takes 33 seconds, with identical output.
`GetLanguageRuntime` now remembers which languages it found no runtime
for, with the target's last section load stop ID, and doesn't search for
them again until that stop ID changes. `Target::ModulesDidLoad` also
forgets them, before anything such as resolving breakpoints can ask for
a runtime. The stop ID alone isn't enough, because modules can load in
two steps at the same stop: when LLDB attaches to a process or loads a
[5 lines not shown]
top: implement pid highlighting
Implement PID highlighting. This can be activated by pressing
'L' and entering a PID to highlight. Highlighting can be cleared
by entering '+' as a PID to highlight. This feature is inspired by
the OpenBSD top, which uses 'P' key for that. We have to use 'L'
because 'P' is already used for toggling per-CPU statistics.
Reviewed by: kib
Obtained from: OpenBSD (partially)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61090
(cherry picked from commit 3dcd4a2fd6b84fe962897f3c07e684ce166798a4)
top: allow filtering by command name
top(1) already supports interactive command filtering using
the '/' key. Support it also with a command line
argument '-g' / '--grep'.
Reviewed by: kib
Obtained from: OpenBSD
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D61160
(cherry picked from commit d668d96259d568877fa863095fc28bd6c323dd01)
[PowerPC] Honor zeroext on widened constant returns in FastISel (#230977)
When returning a constant, PPCFastISel::SelectRet decided between sign
and zero extension by looking at the LocInfo of the return value
assignment. For a return type that GetReturnInfo already widens to i64,
such as zeroext i33 (from unsigned _BitInt(33)), the value is assigned
with LocInfo Full and the zeroext attribute only survives in the output
argument flags. The constant was then sign-extended, so returning
0x1FFFFFFFF produced -1 at -O0.
Also check Outs[0].Flags.isZExt() when choosing the extension.
Fixes #222502.
Co-authored-by: Tony Varghese <tonypalampalliyil at gmail.com>
[LLVM][CodeGen] Fix expansion of ISD::VECTOR_SPLICE_LEFT/RIGHT operations. (#243435)
Expansion goes via memory by converting the vector index into a byte
offset. This is not correct for non-byte based vectors (e.g. <3 x i1>)
with the fix being to first promote the operands to be byte based. This
mirrors the logic used by other vector operations that are expanded
through memory.
[CIR][flang][CMake] Migrate generated-header dependencies
Replace CIR's mlir-headers dependencies and Flang's global MLIR library
lists with actual library dependencies. Declare public header ownership
and keep source shards, bytecode and lowering tables private.
CIRLowering.inc is no longer generated by install-clang-headers; only
transform/lowering sources include it and each consumer lists
CIRLowering. clang_tablegen accepts PRIVATE_TARGET to create it without
registering a global Clang dependency, isolating its output from the
caller's TABLEGEN_OUTPUT. Use add_private_tablegen_target for bytecode
tables, source shards and FIR canonicalization patterns, keeping their
outputs out of later generation targets. Keep
CanonicalizationPatternsIncGen in flang-headers so the header install
still generates every installed .inc file. clangFrontendTool links CIR
libraries privately after creation to preserve LLVM component
visibility, reducing obj.clangInterpreter's prerequisite edges from 579
at the base to 535 and obj.clangFrontendTool's from 1710 to 888.
[22 lines not shown]
[MLIR][CMake] Stop depending on mlir-generic-headers by default
Remove the default mlir-generic-headers dependency from ordinary and
example libraries. Migrate generated-interface requirements to library
owners, including the 17 requirements that become necessary when the
generic default is removed. Keep the compatibility aggregate and
registrations.
MLIRIR also lists MLIRInferIntRangeInterfaceIncGen for Matchers.h. Add
the Transform/Interfaces generator ordering. MLIRDialectUtils uses the
ArithDialect owner for ReshapeOpsUtils.h. Forward MaskableOpInterface's
compile-only MaskingOpInterface dependency through the local helper so
directly compiled libraries receive a bridge too.
MLIRCAPIIR links MLIRInferTypeOpInterface privately. MLIRPass,
MLIRRewrite and MLIRRewritePDL drop their explicit DEPENDS
mlir-generic-headers.
Extend the release note, guide and aggregate-independence regression to
[3 lines not shown]
[MLIR][CMake] Stop depending on mlir-headers by default
Remove the default mlir-headers dependency from the dialect, conversion,
extension and translation library helpers. Keep the aggregate, its
registrations and explicit compatibility dependencies available;
mlir-generic-headers remains a default.
Replace redundant foreign generator edges with library links or
compile-only header owners. Add generator-to-generator ordering where
one generated header includes another. Keep requirements already covered
by generic headers or existing links. MLIRROCDLDialect, MLIRXeVMDialect
and MLIRSPIRVDialect retain private compile-only requirements on
MLIRGPUBase for GPU compilation attribute declarations.
MLIRRewrite drops its PDL generator dependencies; the PDL libraries it
links publish them. Remove redundant C API pass-generator dependencies.
Test aggregate independence for the dialect, conversion, extension and
translation helpers.
[6 lines not shown]
[MLIR][docs] Document the CMake infrastructure
Describe MLIR's TableGen, library, visibility, aggregation, installation
and generated-header conventions in one infrastructure guide. Explain
library owners, explicit generators, compile-only requirements and
add_private_tablegen_target for source-only generators.
Document raw-link bridge usage, generated-header ordering and
unsupported compile-only spellings. Describe the aggregate defaults as
they are today. Link the guide from CreatingADialect.md.
Assisted-by: Codex
[CMake] Propagate generated headers through link dependencies
llvm_add_library made object libraries wait for whole PUBLIC link
providers to obtain generated headers. Publish marked DEPENDS generators
through the LLVM_GENERATED_HEADERS transitive compile property instead,
and order obj.<name> after the evaluated closure through a
<name>.headers bridge target. PRIVATE and transitive compile
requirements participate without compiling provider objects.
Use COMPILE_ONLY for another library's headers without its
implementation. Keep these items build-local, and create a bridge for
directly compiled libraries only when such an item is present.
llvm_add_generated_header_bridge covers items added later. Existing
Windows PCH variants also wait for the owner's bridge. Executables
compiled through obj.<tool> receive a bridge too, without linking their
object libraries to providers.
Shared libraries republish the interfaces of unkeyed links and
components hidden by shared mode. Explicit PRIVATE component
[39 lines not shown]
[bazel] Fix buildifier formatting in llvm/BUILD.bazel (#248996)
#248734 left a double space before the `+` in the Hexagon deps
expression, which fails the Buildifier check on every PR that touches
`utils/bazel`.
[GVN] Scan MemUses of the clobber found by the MemorySSA walker
Previously, if the clobber found in Phase 1 is a MemoryPhi or a
MemoryDef outside the current BB, we proceed directly to Phase
2/3. However, the clobber returned by the walker may still have users
in the current BB, which can be candidates for available values.
As a result, we add support for scanning MemoryUses of the clobber
returned by the walker before proceeding to Phase 2/3.
Assisted-by: Claude # Test
[AMDGPU] Teach isCanonicalized about DS lane intrinsics (#248254)
Teach SelectionDAG and GlobalISel that `ds.bpermute`, `ds.permute`, and
`ds.swizzle` preserve f32 canonicality. Each active destination receives
a whole word from the payload or zero, so a canonical payload is enough
to remove the result canonicalization.
This pattern shows up in the score-max reduction in [Aiter sparse paged
deocde](https://github.com/ROCm/aiter/blob/31f72a40819721a21821c61e6fe81e4187c50ab7/aiter/ops/triton/_triton_kernels/attention/pa_decode_sparse.py#L200-L204),
where a `ds.bpermute` moves a partial max between lanes.
Cover all three intrinsics on both instruction selection paths and keep
the canonicalize when the payload is unknown.
SelectionDAG: Fix marking used physreg defs dead on cloned nodes (#248701)
94a90a694f87 marked an expensive-to-copy physreg def dead on a
scheduler-cloned node if no successor edge was associated with the
register. An edge is only associated with the register if the user
reads it through a glued CopyToReg. If the physreg result is also used
as an ordinary value operand, InstrEmitter emits a copy from the
physreg to a virtual register after each clone of the node.
This left a read of the register after its def was marked dead:
S_CMP_EQ_U32 %16, %17, implicit-def dead $scc
%18:sreg_32 = COPY $scc
Don't mark the def dead if InstrEmitter emitted a copy from the
physreg.
Fixes #247445
Assisted-by: Claude
[AArch64] Prevent sibling calls with stack arguments to `ccc` (#241734)
On AArch64, a tail-marked call from a `tailcc` or `swifttailcc` function
with incoming stack arguments to a `ccc` function may be lowered as a
sibling branch (`b`).
This bypasses the caller's epilogue, which must restore the incoming
stack argument area. As a result, the stack pointer is incorrect when
control returns to the caller of the `tailcc` or `swifttailcc` function.
Reject sibling-call optimization when the caller uses a callee-pops
calling convention and has incoming stack arguments. Calls without
incoming stack arguments and compatible guaranteed tail calls remain
eligible for tail-call optimization.
Fixes #230214
Assisted-by: OpenAI Codex
[libc++] Fix CFI unrelated-cast failures in allocator, __new_at_least, and shared_ptr (#248258)
While working on the CFI CI
(https://github.com/llvm/llvm-project/issues/245696), running the tests
with CFI found three new `cfi-unrelated-cast` failures in libc++. They
were caused by casting newly allocated memory to a typed pointer before
an object is constructed in it. We add
`_LIBCPP_NO_SANITIZE("cfi-unrelated-cast")` to the cases that cannot
avoid the cast. The last case, `__allocate_shared_unbounded_array`, was
casting uninitialized storage to `_ControlBlock*` before `_ControlBlock`
was constructed, so we change it to use placement new on `void*`
directly like `__allocate_shared_impl` does to do the cast after it is
constructed.
Assisted-by: Gemini
[libc][math] fix atan2f rounding in the directed rounding modes (#248976)
This is an issue reported when proving libc math correctness via Lean 4
with an agentic workflow.
We try to prove that `atan2f` is correctly rounded in all rounding
modes. However, for `y = 0x1.d66278p+0f` and `x = 0x1.040e42p+23f` in
`FE_UPWARD`, the result is `0x3467863f`, and the correctly rounded
result is `0x3467863e`.
<details>
<summary>Derivation</summary>
Let `f = 0x3467863e` as a `double`, and let 1 ULP be the unit in the
last place of the double precision result.
1. The exact value of `atan2(y, x)` is `f - 0.24` ULP, so the result in
`FE_UPWARD` is `f`.
2. `q_d = y / x` rounds up to `f + 127` ULP. The index is 0.
[25 lines not shown]
clang: Decide optsize and minsize together with optnone
Instead of adding optsize and minsize everywhere and removing them
when the definition is optnone, only add them to definitions that are
not optnone. Also stop adding these to declarations.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>