[compiler-rt] Use `size_t` rather than `int` for first argument to `__atomic_load_c` et al. (#197519)
I noticed this discrepancy in emscripten when trying to test 128 bit
atomics under wasm64:
https://github.com/emscripten-core/emscripten/pull/26937
The LLVM CodeGen appears to use `size_t` in this position when it
generates calls to these functions.
This doesn't effect other platforms I imagine because they don't require
signature checking at the linker level.
This doesn't effect wasm32 where size_t and int are the same size.
[libc++] Remove AppleClang woraround for __builtin_verbose_trap (#199171)
We've dropped support for AppleClang versions with a different
`__builtin_verbose_trap`, so we can remove the workaround.
Revert "[AIX] Remove unsupported AIX native echo option -n (llvm#199079)" (#199277)
This reverts commit 593eb2066293c8636786c98cb696c533da9b97ca.
The patch is being reverted as the code changes and the commit message
and description do not match and point to a previous implementation
Co-authored-by: himadhith <himadhith.v at ibm.com>
Add --fn flag to llvm-lit to inject select-function pass into opt pipelines
Translates --fn=fn0,fn1 into -passes='select-function<fn=fn0;fn=fn1>,...'
by rewriting -passes= arguments in RUN lines after substitution.
Handles both single and double quoted pass pipelines.
Add select-function pass to keep only specified functions and their dependencies
Chains InternalizePass, GlobalDCEPass, and StripDeadPrototypesPass to
remove everything not transitively reachable from the selected functions.
Supports multiple roots via select-function<fn=foo;fn=bar>.
[offload] Fix --libomptarget-nvptx-bc-path in tests
PR #198622, which landed as 3383f0d6fe01, causes 272 `libomptarget ::
nvptx64-nvidia-cuda` test fails on my system with:
```
clang: error: bitcode library '/home/jdenny/llvm/build/\./lib/x86_64-unknown-linux-gnu/nvptx64-nvidia-cuda' does not exist
```
This patch fixes that.
[RISCV] Reserve all sub-registers of user reserved GPRs (#199302)
When a GPR is reserved by the user (e.g., via `-mattr=+reserve-x27`)
or marked as constant, only the top-level register was being marked
reserved in `RISCVRegisterInfo::getReservedRegs`. Its sub-registers
(`X27_W` and `X27_H`) remained unreserved.
This broke `LiveIntervals` when register pressure tracking was enabled
by #115445. Because the sub-registers were not reserved, the register
unit was considered non-reserved, causing `LiveIntervals` to track its
liveness and crash in the Machine Verifier due to the reserved
register missing from basic block live-in lists.
Instead, we should ensure that reserving a register also reserves all
of its sub-registers, so that the register unit is correctly
identified as reserved and ignored by `LiveIntervals`.
Fixes #176227
[VPlan] Create casts before ComputeReductionResult (NFC). (#199372)
This ensures ComputeReductionResult is created with operands that have
their correct types set at construction.
[LV] Don't add stride SCEV predicates when runtime checks are disabled. (#199370)
Don't pass symbolic strides to getPtrStride if SCEV runtime checks are
not allowed (e.g. because optimizing for size). This prevents
getPtrStride from adding additional SCEV checks for symbolic strides.
[VPlan] Thread types through VPHeaderPHIRecipe and VPDerivedIVRecipe (NFC) (#195894)
Update VPHeaderPHIRecipe and VPDerivedIVRecipe to set the scalar types
for their defined values.
This requires updating addReductionResultComputation to construct the
new chain for AnyOf reductions up-front.
Depends on https://github.com/llvm/llvm-project/pull/195891
PR: https://github.com/llvm/llvm-project/pull/195894
[SimplifyLibCalls] Don't set nnan on synthesized frem in optimizeFMod (#199284)
LibCallSimplifier can fold a libcall to fmod to an frem instruction if
the fmod call doesn't set errno.
fmod(x, y) sets errno if x == +/-Inf or y == 0. The old code assumed
that this was also a sufficient condition to prove that the result is
not NaN, and so unconditionally set the nnan fmf on the new frem
instruction. That's not sound; e.g. fmod(x, NaN) == frem(x, NaN) ==
NaN.
We don't actually have to worry about propagating the `nnan` flag;
B.CreateFRemFMF does it for us automagically.
This bug was found by a large run of Opus 4.7 looking for bugs in LLVM.
[SimplifyLibCalls] Fix optimizeFdim for Inf-Inf cases (#199306)
fdim(x,y) is defined as
NaN if x or y is NaN, otherwise
(x > y) ? x - y : +0
optimizeFdim computed fdim(x,y) as max(x-y, +0). This is not correct
when x == y == +/-Inf; the result should be 0, but this optimization
returns NaN.
I was surprised by this bug because there's even a testcase checking the
incorrect behavior. But returning 0 matches the description in C99 and
POSIX, where, just to be extra clear, the spelling of the piecewise
function is
NaN if either input is NaN
x - y if x > y
+0 if x <= y
[4 lines not shown]
[clang] Fix crash in getCursorRawComments. (#199328)
Fix a regression introduced in PR #198452 where querying raw comments on
invalid cursors caused a segmentation fault due to unconditional
ASTContext lookup. Adding an early exit for unsupported cursor kinds at
the top of getCursorRawComment safely avoids resolving the context on
invalid cursors with null translation units.
[LV] Determine NumPredStores before computing widening costs. (#199341)
Determine NumPredStores before computing widening costs, so we
consistently apply large predicated store cost to all stores, matching
the VPlan cost model. In practice that should not impact vectorization
decisions, as the huge cost for any predicated store other than the
first already effectively disables vectorization.
[Analysis][AIX] Add !implicit.ref globals as ThinLTO summary ref edges to support pragma comment(copyright) LTO interaction
Teach ModuleSummaryAnalysis to include globals referenced via
!implicit.ref metadata as explicit reference edges in the ThinLTO
module summary via a new helper findImplicitRefEdges.
[PowerPC][AIX] Support #pragma comment copyright for AIX
- Emit !aix.copyright.comment from Clang for the pragma.
- Lower it in LLVM to a TU-local string + llvm.used + !implicit.ref.
- Add module-import and backend relocation tests.
[libc++][test] Merge test files for `mdspan::at` (#199330)
`libcxx/test/libcxx/containers/views/mdspan/mdspan/assert.at.pass.cpp`
caused build bot failures for
- sanitizer-aarch64-linux-bootstrap-asan
- sanitizer-aarch64-linux-bootstrap-hwasan
- sanitizer-aarch64-linux-bootstrap-msan
It's not yet clear why current mechanisms don't work for these builds.
`TEST_HAS_NO_EXCEPTIONS` should have been working.
Also remove one unnecessary `static` and use `std::string_view(e.what())
== "mdspan"`.
[DAG] UDIV/SDIV exact nodes support DemandedElts + add test (#198715)
Resolves #183047
This patch updates isKnownNeverZero to handle DemandedElts for UDIV and SDIV exact nodes.