[llvm][cas] Fix indefinite wait for CAS shared locks (#236929)
On Darwin, flock may only wake a single waiting shared lock request
after an exclusive lock is released. If that first waiter happens to be
a long-running CAS client, it may indefinitely delay other waiting
shared accesses that are already queued up. Workaround this with a retry
loop so that all shared CAS clients will run concurrently.
Assisted-by: claude (helped with writing the test)
rdar://191274568
Return ENODEV from vdev_prop_get/set for a missing vdev
Return ENODEV instead of ENOENT when a vdev guid lookup
fails so zpool commands report a vdev that disappeared as
"no such device in pool" rather than "no such pool or dataset".
Reviewed-by: Alexander Motin <alexander.motin at TrueNAS.com>
Signed-off-by: Mark Maybee <mark.maybee at delphix.com>
Assisted-by: Claude Sonnet 5.5
Closes #19594
SelectionDAG: Build FP immediates from integer bits in the legalizer (#233767)
Teach the generic legalizer to legalize FP immediates as a bitcast of
an opaque integer constant. Migrate LoongArch to use the new helper
instead of doing it in custom lowering.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[SystemZ][z/OS] Add missing ADA reference to DWARF sections
Labels marked as DATA needs a reference to the ADA. However, this
is missing for the DWARF sections, which can lead to crashes in
certain scenarios. Fix is to set the ADA reference.
Assisted by: IBM Bob
[clang][ThreadSafety] Instantiate a parameter's attribute naming a later parameter (#232784)
Under -fexperimental-late-parse-attributes, an attribute on a parameter
may name a parameter declared after it:
template <class T> void f(void (*release)(T) RELEASE(mu), Mutex *mu);
A parameter's attributes were instantiated as the parameter was, before
any later one, so instantiating this asserted in
LocalInstantiationScope::findInstantiationOf, and the late parsing
change rejected it in a template. Defer a parameter's late-parsed
attributes, with the mechanism a class uses for its members, until every
parameter of the prototype is instantiated in
TransformFunctionTypeParams. A function whose type needs no substitution
instantiated its parameters one by one instead; route it through
SubstParmTypes, so there is one place that defers. SubstParmTypes now
takes whether to evaluate constraints, which SubstFunctionType passes in
both of its calls, so a typedef'd function type also follows the
instantiator's setting instead of always evaluating them. With that,
[3 lines not shown]
ARM: Remove kill flags on virtual registers from MIR tests (#236921)
The verifier will soon disallow these. Delete tests which only differ
from another in the kill flags.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[clang][ThreadSafety] Resolve fields named from nested struct/union members (#233965)
Some real-world projects (e.g. the Linux kernel) rely on naming locks in
the enclosing record, rather than siblings of the annotated member. This
is effectively a new feature, but projects already relied on it, because
`&lock` used to be misread as the `&Scratch::lock` wildcard, meaning any
object's `lock` (corrected in llvm/llvm-project at 217e229a1f32, reverted
in llvm/llvm-project at 51ec77936fb5 until this merges).
This will fix the issue reported in
https://github.com/ClangBuiltLinux/linux/issues/2187.
The nested struct or union may be named or anonymous, and its member may
be reached through a member, an array element, or an address-of or
dereference; all are handled the same way. A name resolves to the
innermost struct declaring it. Members of an anonymous struct or union
may likewise be named by attributes on the enclosing struct.
```c++
[45 lines not shown]
[PatternMatch] Made m_FNeg match only fneg instructions (#235348)
`m_FNeg` also matches `fsub -0.0, X` and forms like `fsub nsz +0.0, X`.
This is incorrect as fneg only flips the sign bit, while a subtraction
from zero follows full FP arithmetic and may quiet a QNaN
Fixes #234426.
Fixes #233341.
[X86][APX] Use CSR first-use cost 1 with PPX (#235644)
With PPX, push/pop pairs don't access memory, so getCSRFirstUseCost()
returns 0. That disables RegAllocGreedy's frequency-weighted trade-off
between using a new callee-saved register and splitting/spilling the
live range, so small hot functions save and restore CSRs in the entry
block on every call instead of spilling around the calls on cold paths.
The saves are still executed instructions.
Return a first-use cost of 1 instead of 0 when PPX is available. Targets
without PPX keep a cost of 2.
Assisted by: Claude Opus 5.5 <noreply at anthropic.com>
[compiler-rt] Remove dlsym interceptor and support `-shared-libsan` for CSan
Summary:
Follow the UBSan offload runtime. Offload now resolves HSA through the
global scope, so the `dlsym` interceptor is no longer needed. The real
HSA entry points are still taken from the loaded HSA library rather than
`RTLD_NEXT`, since every DSO with a static runtime exports the same
wrappers and they would otherwise chain back into each other.
Build `libclang_rt.csan.so` with the offload objects folded in. The
exported HSA wrappers report failure when HSA is absent and warn when HSA
was loaded ahead of the runtime. The preinit hook moves to a separate
`csan_offload-preinit` archive for executables.
[compiler-rt] Add 'csan' library for the concurrency sanitizer
Summary:
Adds the runtime for the concurrency sanitizer, both CPU and GPU.
Fundamentally, this works using the following pseudocode:
```c
static u64 watchpoints[N]; // Hash-indexed, zero is empty.
// Emitted before the access, so we never trip on our own write.
void check_access(volatile void *addr, u32 size, u32 type) {
// Every access probes. A read conflicts only with a watched write, a
// write conflicts with either.
if (u64 *wp = find_watchpoint(addr, size, type))
consume(wp, this_pc()); // Hand our location to the owner.
if (!should_sample()) // Wave-uniform, 1-in-N chance.
return;
[17 lines not shown]
[Clang] Support `-shared-libsan` for offload CSan
Summary:
Follow the UBSan handling. The shared runtime embeds the HSA
interceptors, so `csan_offload` is only linked with static runtimes and
executables pull in `csan_offload-preinit` to initialize early.
[Clang] Add support for the `-fsanitize=concurrency` runtime
Summary:
Add the frontend sanitizer kind, function attributes, pass pipeline
integration, predefined macro, driver handling, and documentation for
ConcurrencySanitizer.
Keep distinguished volatile reads before a later write
A volatile write is reported as atomic, so it does not cover an earlier
plain read. A smaller write or an intervening acquire still drops the
read, matching ThreadSanitizer.