[libc][sys/shm] Implement shmdt syscall wrapper on Linux. (#239785)
`shmdt` is a POSIX function (see
[docs](https://pubs.opengroup.org/onlinepubs/9799919799/functions/shmdt.html#))
that detaches the shared memory segment from the address space of a
calling process.
On Linux, it can be implemented as a simple wrapper around SYS_shmdt
syscall.
Provide the implementation, and add a simple test case verifying it only
works correctly on addresses returned by `shmat` call.
[RISCV] Report errors for user reserving argument/return registers with Zhinx/Zfinx. (#239384)
Zhinx/Zfinx can use X10_H-X17_H or X10_W-X10_H subregisters. These were
not tracked in the bitvector in RISCVSubtarget.
The subtarget now contains a 32 element bitset for just the X registers.
The full bitset has moved to RISCVRegisterInfo where it is populated
with the aliases in the constructor.
RISCVRegisterInfo::getReservedRegs now uses the 32 element bitset. This
required moving the constant registers out of the loop and reserving
them explicitly. Alternatively, we could use the full bitset here, but
since we use markSuperRegs, we'd end up visiting registers multiple
times.
I've kept an accessor for the full bitset in RISCVSubtarget to avoid
touching all callers.
Assisted-by: Claude
AMDGPU: Remove clearKillFlags calls
Kill flags on physical registers here are either never set by the
time this code runs or are on reserved or constant registers where
they carry no information. Remove the clearKillFlags calls.
SIPeepholeSDWA was adding a kill flag on the virtual register it ties
to the preserved destination and relying on the clear to remove it.
Stop adding it.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
MachineSink: Remove clearKillFlags calls
Kill flags on physical registers here are either never set by the
time this code runs or are on reserved or constant registers where
they carry no information. Remove the clearKillFlags calls.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
LoongArch: Remove clearKillFlags calls on virtual registers
Kill flags are no longer permitted on virtual registers, so clearing
them is a no-op. Remove the calls where the register can only be
virtual.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
PowerPC: Remove clearKillFlags calls on virtual registers
Kill flags are no longer permitted on virtual registers, so clearing
them is a no-op. Remove the calls where the register can only be
virtual.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
X86: Remove clearKillFlags calls on virtual registers
Kill flags are no longer permitted on virtual registers, so clearing
them is a no-op. Remove the calls where the register can only be
virtual.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RISCV: Remove clearKillFlags calls on virtual registers
Kill flags are no longer permitted on virtual registers, so clearing
them is a no-op. Remove the calls where the register can only be
virtual.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[RISCV] Drop MachineDominatorTreeWrapperPass in Zilsd optimizer (#239783)
The last use of MachineDominatorTreeWrapperPass in
RISCVZilsdOptimizer.cpp was removed on November 6, 2026 in commit
d8ce3e5f727698eacfc46687562e5c53ab7c7241.
This patch removes the unused MachineDominatorTreeWrapperPass dependency
and MachineDominators.h include from RISCVZilsdOptimizer.cpp. Dropping
this dependency defers MachineDominator Tree Construction in the legacy
RISC-V -O3 pipeline until right before Slot index numbering.
Assisted-by: Antigravity
X86: Remove dead kill flag maintenance in X86AvoidStoreForwardingBlocks (#239777)
This pass runs before register allocation, and the verifier now
rejects kill flags on virtual registers.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[ConstraintElim] Split signed min/max across their operands when checking a compare
The existing constraint systems only record the bounds that hold for both
operands of a min/max (smax(a, b) >= a and >= b, smin(a, b) <= a and <= b). The
other direction is a disjunction, which cannot be recorded as a fact. When a
compare of signed decompositions involves a min/max result, split it into its
operands: the decomposition is monotonic in that result, so it is the max or min
of its values on each side, and the relation holds for all or for either side
respectively.
https://alive2.llvm.org/ce/z/zsGkJ-
[ConstraintElim] A signed sum of operands with opposite signs cannot wrap
If one operand is known non-negative and the other non-positive, the signed
sum is between them, so it cannot overflow.
https://alive2.llvm.org/ce/z/ZF5Yqr
[ConstraintElim] Prove sadd/ssub.with.overflow cannot overflow from the exact sum
Decompose the operands and show that the sum lies in the range of the type. This
handles patterns like A + (B - A), as well as sums involving signed min/max
results, which are split across their respective operands using monotonicity
(for example start + smax(end - start - 1, 0) <= end).
https://alive2.llvm.org/ce/z/ze8LCk
AMDGPU: Remove clearKillFlags calls on virtual registers (#239780)
Kill flags are no longer permitted on virtual registers, so clearing
them is a no-op. Remove the calls where the register can only be
virtual.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Hexagon: Remove clearKillFlags calls on virtual registers (#239781)
Kill flags are no longer permitted on virtual registers, so clearing
them is a no-op. Remove the calls where the register can only be
virtual.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc] Don't match the byte after the range in vector find_first_character (#235288)
The vectorized `find_first_character` implementations (`clang_vector`
and the x86_64 `arch_vector`) returned the position of a match that was
the first byte after the searched range. For example, `memchr("ab", 'b',
1)` returned a pointer to the `'b'` instead of `nullptr`.
The new test covers all implementations, since no configuration selects
the vectorized ones by default. On aarch64 Linux, it fails without the
fix and passes with it. The x86_64 changes were only compiled, not run.
Assisted-by: Claude Code (Claude Opus 5.5)
[libc] Don't read memory in vector find_first_character if n is 0 (#235289)
The vectorized `find_first_character` implementations (`clang_vector`
and the x86_64 `arch_vector`) loaded the aligned block containing the
start pointer before checking the length. With a length of zero, the
pointer doesn't have to be dereferenceable, so `memchr(p, c, 0)` and
`strnlen(p, 0)` crashed if `p` was the start of an inaccessible page.
The new test covers all implementations, since no configuration selects
the vectorized ones by default. On aarch64 Linux, it segfaults without
the fix and passes with it. The x86_64 changes were only compiled, not
run.
Assisted-by: Claude Code (Claude Opus 5.5)
[DAG] Fold fp_to_int(ftrunc(x)) -> fp_to_int(x) (#231060)
fp_to_[su]int already rounds toward zero, so an ftrunc in front of it
does nothing and can be dropped. fp_to_[su]int_sat is the same since it
truncates before it clamps.
x86 hits this through LowerFROUND which expands round into a copysign
add plus an ftrunc so (long)roundf(x) keeps a vroundss that the convert
makes pointless.
The AArch64 test changes are shapes its isel patterns don't cover,
mostly f16 and bf16.
On RISC-V llvm.trunc on some test cases turns into an fabs, a compare,
an fcvt round trip and an fsgnj, or a call to trunc, and all of it goes
away.
AMDGPU runs integer division through a float reciprocal. The i32 cases
each lose a v_trunc_f32. The i64 files only change register numbering
[7 lines not shown]
[X86ExpandPseudo] Don't preserve CFG unconditionally (#239756)
As in title. CFG can't be preserved unconditionally because it is
sometimes changed. Add newpm line to affected test
[PowerPC] Custom-lower `f128` `BR_CC` for VSX w/o P9 (#230758)
`f128` is legal in VSX registers, but actual operations are softened
prior to P9. Expanding a `BR_CC` does not soften the compare; it only
legalizes the condition code, which is already legal, so we hit the
assertion:
assert(Legalized && "Can't legalize BR_CC with legal condition!");
`LowerBR_CC()` already handles both aspects correctly for SPE, so just
repurpose that for this case, similar to other backends.
closes https://github.com/llvm/llvm-project/issues/171869
[flang][OpenACC] Reject real explicit acc loop bounds in semantics (#239258)
Follow-up to f8897bb9f "[flang][OpenACC] Convert real DO controls for
implicit acc.loop". That change converts a REAL DO control of an
implicit acc.loop to the induction variable's integer type. An explicit
!$acc loop must have integer bounds, but semantics did not check them,
so a REAL lower bound, upper bound, or step reached lowering. With a
REAL upper bound and no step, lowering built the default step from the
REAL type and aborted:
error: expected integer or index type
Check the lower bound, upper bound, and step of each loop associated
with an explicit directive in CheckAssociatedLoop, including COLLAPSE
nests. A REAL expression is reported as "OpenACC loop bound expression
must have INTEGER type". Implicit acc loops are checked during lowering,
where a non-integer control is converted to the induction variable's
integer type. DO CONCURRENT does not pass its step to the semantic
check, because its step is parsed as ScalarIntExpr.
[6 lines not shown]
[flang][OpenACC] Resolve the DELETE and NO_CREATE clause operands (#239677)
A named common block in a `delete` or `no_create` clause produces an
internal error instead of being resolved:
```fortran
subroutine s
integer :: a
common /c/ a
!$acc enter data create(/c/)
a = 1
!$acc exit data delete(/c/)
end subroutine
```
```
error: Internal: no symbol found for 'c'
!$acc exit data delete(/c/)
^
[55 lines not shown]
X86: Keep the TargetMachine alive in TernlogTest (#239759)
The TTI callback destroyed the TargetMachine it created before the
returned TTI was used, leaving it with dangling pointers. It just
happens this test never reads from these pointers today, so no
sanitizer reports this.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RISCV: Remove clearKillFlags calls on virtual registers
Kill flags are no longer permitted on virtual registers, so clearing
them is a no-op. Remove the calls where the register can only be
virtual.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[libc][scudo] Use RUNTIMES_USE_LIBC to decide if scudo uses LLVM-libc (#239496)
`RUNTIMES_USE_LIBC` CMake flag is now responsible for defining which
libc is
used to build compiler-rt runtime libraries. In particular, it provides
`runtimes-libc-headers` interface library, which achieves three
important goals
when we're using `llvm-libc`:
* sets up proper include directories to use LLVM-libc headers;
* ensures that LLVM-libc generated headers will be produced;
* Adds `-nostdlibinc` and propagates Linux kernel headers inclusion
paths so that
they match what LLVM-libc itself is using.
Instead of using ad-hoc flag
`COMPILER_RT_BUILD_SCUDO_STANDALONE_WITH_LLVM_LIBC`
just rely on the value of `RUNTIMES_USE_LIBC=llvm-libc` when we're
building Scudo
allocator for use with LLVM-libc. Importantly, this fixes the
[19 lines not shown]