[VPlan] Only retain NSW when possible in getFlagsFromIndDesc. (#226315)
getFlagsFromIndDesc is used to get the flags to use for wide inductions.
Those are normalized to Adds, with the step negated if the induction
binop is Sub.
Only retain all flags for Add. For Sub, never retain NUW and only keep
NSW if the step is known to not be signed min.
Alive2 Proofs showing incorrect NUW/NSW transfer and transfer of NSW if
step is != signed INT_MIN: https://alive2.llvm.org/ce/z/zGKeZg
Fixes https://github.com/llvm/llvm-project/issues/224024.
TargetMachine: Remove DataLayout field
Keep createDataLayout around but mark it as deprecated. Eventually
the ABIName field will move out of MCTargetOptions, which can change
the datalayout.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
TargetMachine: Remove pointer-size query methods
Remove the shim methods from the TargetMachine's copy of the
DataLayout, which will soon be eliminated. The Module owns the authoritative
DataLayout, so callers should read the value from the contextual Module.
Completely unreasonably, Mips's ABI name can change the pointer size which
we probably should just not support. Many other triple checks will never be
correct. This avoids potential mismatches in these contexts, but I still expect
this to be widely broken.
Some of the TargetLowering constructor changes and AMDGPULegalizerInfo
changes are kind of annoying. We could pass in the DataLayout through
the subtarget constructors but it didn't seem worth the effort and
the information should be derivable from the triple anyway.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[clang] Drop explicit -Woverloaded-virtual build option (#225359)
Nowadays, Clang and GCC have reasonable (and aligned) default
`-Woverloaded-virtual` warnings when using `-Wall`. Fall back to this
default and omit the more aggressive `-Woverloaded-virtual` warnings
only present in GCC's level 2 mode of the warning.
The motivation for this change is discussed in the following RFC:
https://discourse.llvm.org/t/rfc-drop-explicit-woverloaded-virtual-clang-build-option/91857
Removing the explicit `-Woverloaded-virtual` build option also allows
removing the workaround from e1bd39c.
[lldb-dap] Create telemetry data only when built with telemetry. (#225785)
I am exploring fuzzing some parts of lldb-dap. but there is a fixed
amount of memory lldb-dap can use before the fuzzing stops to catch
memory leaks.
The telemetry dispatcher always creates telemetry regardless of if lldb
is built with telemetry enabled.
`SBStructuredData::SetFromJSON` adds the telemetry string to the
ConstString pool for every request and grows lldb-dap's memory usage
rapidly.
[orc-rt] Make Expected's move operations conditionally noexcept. (#226393)
Expected<T>'s move constructor and move assignment operator are now
noexcept whenever T's storage type is nothrow-move-constructible.
Error's move operations are already noexcept, so this is the only
condition under which moving an Expected can throw.
This allows callables that take Expected<T> by value to be stored in
noexcept-qualified move_only_functions: is_nothrow_invocable includes
the initialization of by-value parameters, which previously used
Expected's potentially-throwing move constructor.
[lit] Include zero-duration tests in the --time-tests histogram (#226132)
`--time-tests` treated an elapsed time of 0 as missing, so they were
omitted from the histogram. That made time-tests.py flaky when FileCheck
expected every test to be listed.
The PR also avoids log(0) when every recorded time is zero.
Fixes
https://github.com/llvm/llvm-project/pull/208444#issuecomment-5805067757.
[LLVM] Fix typo "CxtI" (#226137)
LLVM had many instances of both "CxtI" and "CtxI". This patch
standardizes on the latter. I regard the former as a mistake that should
never have spread. In general usage, "ctx" is much more common as an
abbreviation for "context".
Same for "CxtF" and "CxtPhi" which occurred a few times each.
Also fix the few instances of "Cxt" to "Ctx", which was already
overwhelmingly more common.
[libc] Fix chmod syscall arguments and add symlink test (#226144)
Our Linux chmod wrapper had two bugs in how it invoked syscalls:
- the fchmodat syscall only takes three arguments (dfd, filename, mode),
but we were passing four (with a trailing 0 for flags).
- for fchmodat2, we were (mistakenly) passing AT_SYMLINK_NOFOLLOW, even
though chmod is specified to follow symlinks.
I reorder the checks to prefer fchmodat2 (with flags=0) if available,
and otherwise invoke fchmodat with the three arguments it expects.
I also add a test to verify that chmod follows symlinks and updates the
target file's permissions, and that attempting to chmod a dangling
symlink fails with ENOENT.
Assisted-by: Gemini
[RISCV] Remove getMaxLMULForFixedLengthVectors. NFC (#226111)
The value can no longer be overridden after
https://github.com/llvm/llvm-project/pull/207312. Now there's nothing
specific about it to fixed vectors, so just inline it.
[RISCV] Fix scalable expandload lowering for i8 types (#225141)
This PR adds tests for scalable expandload/compressstore intrinsics, and
also fixes a crash where we tried to query getVectorNumElements on a
scalable vector for i8 element types.
We need to use vrgatherei16 when VLMAX may exceed 255, so compute this
for scalable vectors based off of getRealMaxVLen.
This is in preparation for compress pattern vectorization support in
https://github.com/llvm/llvm-project/pull/214491
[libc] Implement pselect in sys/select (#226237)
Implement the standard POSIX.1-2008 / POSIX.1-2024 function `pselect` in
`<sys/select.h>`, bringing `<sys/select.h>` to 100% POSIX completion.
Fixes #226195.
[AMDGPU] Use CFG in LIRP tests (#226260)
LIRP tests (llvm/test/CodeGen/AMDGPU/lirp.mir) use live intervals with
gaps and redefinitions.
With added -verify-machineinstrs, current test examples trigger machine
code check failure ("Multiple connected components in live interval").
This PR updates the tests to use CFG (loops with loop-carried vregs)
similar to the real world use cases, to fix the verification, and also
simplifies the tests a bit (using implifit defs and kills).
Test:
```
ninja -C build
ninja -C build check-llvm
./build/bin/llvm-lit -v llvm/test/CodeGen/AMDGPU/lirp.mir
```
[VPlan] Append recipes created via builder to worklist
The previous PR appended the top most created recipe to the worklist, and this PR extends it to any other nested recipes that were created, similar to InstCombine.
This removes the header mask in a good few more places on RISC-V as measured on SPEC CPU 2017, e.g. for the following loop:
```c
long f(const int *p, const int *q, long n) {
long a = 0, b = 0;
for (long i = 0;; i++) {
if (p[i] && q[i]) { a += i; b += i; }
if (i + 1 == n) break;
}
return a + b;
}
```
Before:
[49 lines not shown]
[RISC-V] Do not emit cm.popret[z] with zicfiss (#196267)
When emitting shadow call stack protection instructions, the push/pop
optimization needs to be turned off because an sspopchk before a
cm.popret[z] is guaranteed to fail in a non-leaf function. In addition,
the sspopchk must be emitted after a cm.pop so that the ra has the
correct value when the check is performed.
Fixes: https://github.com/llvm/llvm-project/issues/196261
Co-authored-by: Nemanja Ivanovic <nemanja at synopsys.com>
(cherry picked from commit 255162ae0ebe805df151c5c4b48e1a47a5dd74f0)
[RISC-V] Fix assert after 255162a (#212791)
The iterator passed-in may point to the end of the block which causes an
assertion failure when attempting to inspect the MI it points to. Guard
against this.
(cherry picked from commit f24da9d03ba5d25c523e050da2ca3c4060ca23d5)
[AArch64] Don't emit stack restore for SME ZA non-sibling tail calls (#224721)
A tail call from a function with live ZA state was previously prevented
from being lowered as a sibling call to have a CALLSEQ_START to glue
INOUT_ZA_USE to. This led to bogus stack restores.
We now drop the INOUT_ZA_USE marker on tail calls and can thus lower as
sibling calls if needed to take advantage of the existing correct stack
restore behavior.
This is safe to do since tail calls use TCRETURN and the MachineSMEABI
pass requires live ZA state to stay live across returns anyway.
(cherry picked from commit ad695d46e4535f953558705541b71c2d938fb72b)