[Offload] Bring back LocalMem skips for L0 (#246068)
Added a SKIP in offload tests, because newly added module-flag is not
added when building test kernels. More on the module-flag here
https://github.com/llvm/llvm-project/pull/231160
[LLDB] [CMake] Allow linking with SABI Python on Mingw (#245600)
For the Python stable ABI/API, we currently don't link directly against
the Python library at all. On Unix platforms, we expect to dlopen() the
Python library before loading liblldb. On Windows in MSVC environments,
the right Python library is linked implicitly through `#pragma
comment(lib, ..)`.
For Mingw environments, we do need to explicitly link against the right
library. Locating the right library requires including
`Development.SABIModule` in the `find_package(Python3 ..)` call. This
requires CMake 3.26 or higher, and since
eb9bb7d826f80cecc675c0bfa0ec4b61eb1be05a, LLVM requires CMake 3.31 or
newer.
(In practice, it was benign to include this in the `find_package()` call
on older versions of CMake, it would just warn that this feature wasn't
known though, and it wouldn't set the right variables unless running
with a new enough version of CMake.)
[CIR] Use the pragma FP environment for __builtin_convertvector
`ScalarExprEmitter::VisitConvertVectorExpr` emitted the conversion
without a `CIRGenFPOptionsRAII`, so the cast got the floating-point
environment of the command line instead of the one that pragmas set at
the expression. With `-ffp-exception-behavior=strict` on the command
line and `#pragma clang fp exceptions(maytrap)` plus
`#pragma STDC FENV_ACCESS ON` in the function, ClangIR lowered the
conversions to constrained intrinsics with `round.tonearest` and
`fpexcept.strict`, where classic codegen emits `round.dynamic` and
`fpexcept.maytrap`.
Install the RAII for the conversion, after the source operand is
emitted, as classic codegen does on each floating-point path.
The test converts between float vectors and signed, unsigned, double
and bool vectors, so it covers the `float_to_bool` and `bool_to_float`
casts too. ClangIR and classic codegen share every LLVM check for them,
and the ClangIR run rejects any plain conversion or `fcmp` instruction
[7 lines not shown]
[CIR] Keep complex and bool casts constrained in strict FP functions
In a strictfp function ClangIR emitted plain `fpext`, `fptrunc`,
`fptosi`, `sitofp`, `uitofp` and `fcmp une` for casts between complex
types and for conversions between floating-point values and bool, where
classic codegen emits constrained intrinsics. CIRGen created the
complex casts and `float_to_bool` without the `fenv` attribute,
LoweringPrepare dropped the attribute when it expanded a complex cast,
and the LLVM lowering of `float_to_bool` and `bool_to_float` ignored
it.
`createCast` now takes an optional `fenv` attribute. CIRGen passes the
current floating-point environment for `float_to_bool` and for the
complex cast kinds that convert floating-point values. The kinds that
only select or pack a part, `float_to_complex` and
`float_complex_to_real`, get none, and the verifier no longer accepts
the attribute on them. LoweringPrepare passes the attribute of a
complex cast to the scalar casts of its expansion. With `fenv`,
`float_to_bool` lowers to the quiet constrained `fcmp` and
[10 lines not shown]
[openmp] Remove obsolete `REQUIRES: flang` from test (#244914)
Remove `REQUIRES: flang` from the one test using it, as the feature is
no longer defined within `openmp` (it is in `offload`), and therefore
the test was always skipped. Fortran tests are disabled entirely (by
suffix) when Flang is not available.
Signed-off-by: Michał Górny <mgorny at gentoo.org>
[CIR] Keep three-way comparisons constrained in strict FP functions
In a strictfp function ClangIR emitted plain `fcmp` for a three-way
comparison of floating-point values, where classic codegen emits
`llvm.experimental.constrained.fcmp`. `cir.cmp3way` had no `fenv`
attribute, and LoweringPrepare expanded it with a builder that has no
floating-point state.
This gives the operation the optional `fenv` attribute, valid only for
floating-point operands, and the fenv traits of the scalar operations
in place of `Pure`:
- CIRGen attaches the attribute. Like classic codegen it opens no
FP-options scope for the comparison itself, so the comparison takes
the environment in effect around it. In `return x <=> y` under
`FENV_ACCESS ON` alone that is the default of the function,
`fpexcept.ignore`.
- LoweringPrepare expands a comparison of floating-point values into
quiet `cir.fcmp`s, which take the attribute if the operation has one.
[10 lines not shown]
[Hexagon] Support UPMUCNT[0-7] register aliases (#244679)
Registers UPMUCNT0-UPMUCNT7 are added in v79 and are aliases for control
registers C20-C27. According to the PRM, these registers are read-only.
Fixes #233538.
[Hexagon] Allow two shifts per packet in HVX v79+ (#245319)
In Hexagon v79 and later, two shift instructions (CVI_VS) can be
scheduled in one packet, compared to one in previous versions. The
second shift instruction will use the permute resource, which was
renamed to a shift/permute resource in the documentation.
However, there are restrictions when using the shift/permute resource
for shift instructions. First, a small subset of shift instructions (the
four 3-source narrowing shifts and 3 vprefix instructions) may still
only use the shift resource even in v79 and later.
Second, the 3-source shifts cannot be packetized together with another
shift.
Co-authored-by: Yashas Andaluri <yandalur at qti.qualcomm.com>
NAS-145438 / 27.1.0 / Fix flaky NFS logging test (#20321)
We'll have to use NFSv3 to test logging. NFSv4 mounts only produce the
inotify-driven "v4.x client attached/detached" lines, which are racy.
Also, WARNINGs like "refused unmount not exported" pass the simple
`'rpc.mountd' in syslog_data` filter and can mess with tests results
too.
[CIR] Keep complex mul and div constrained in strict FP functions
In a strictfp function ClangIR emitted plain `fmul`, `fsub`, `fadd`,
`fdiv` and `fcmp` for complex multiplication and division, where
classic codegen emits constrained intrinsics. `cir.complex.fmul` and
`cir.complex.fdiv` had no `fenv` attribute, and LoweringPrepare
expanded them with a builder that has no floating-point state.
This moves both operations onto `CIR_FenvOp`, which gives them the
optional `fenv` attribute and the fenv traits of the scalar operations.
CIRGen attaches the attribute, and LoweringPrepare passes it to the
scalar arithmetic, comparisons and conversions of the expansion.
The range check of the improved division becomes a quiet
`cir.fcmp ugt`, the predicate classic codegen uses. A `cir.cmp ge` with
`fenv` lowers to the signaling `fcmps` and would raise an invalid
exception for a quiet NaN divisor. Without `fenv` the check changes
from `fcmp oge` to `fcmp ugt`.
[15 lines not shown]
[clang] Use the operator's FP environment for promoted operands
An operator evaluated in a wider type converts its operands to that type
and its result back. This happens for `_Float16` and `__bf16` without
native support, and for complex division with the promoted complex
range. The binary operators and unary plus and minus did these
conversions outside the scope of their FP options, so the conversions
took the ambient options. The right-hand side of a scalar compound
assignment was promoted before its scope too. For `z = x * y` on
`_Float16`, or `c = a / b` on `_Complex float` with the promoted range,
under a file-scope `#pragma STDC FENV_ACCESS ON`, that is the default
environment of the function:
fpext fpexcept.ignore -> fpexcept.strict
fptrunc round.tonearest, fpexcept.ignore -> round.dynamic, fpexcept.strict
`c /= b` and `f(a / b)` already had the strict metadata, because the
scope of the compound assignment or of the call was open. These
operators now open their scope before they promote, when they promote.
[4 lines not shown]
[wasm] Swift async ABI p3: Lower llvm.swift.async.context.addr to local 0
With this commit, in functions with a swiftasync argument, the async
context intrinsic is lowered to local 0. Without a swiftasync argument,
the intrinsic is a stack slot, as on X86 without an extended frame.
Loads and stores through llvm.swift.async.context.addr become local.get 0
and local.set 0. Other uses of the address are an error, because locals
have no address.
The swiftasync argument also arrives in local 0, so the argument and the
intrinsic are two names for the same location. After a write through one of
them, a read through the other returns the wrong value. Await resume funclets
write their own context through the intrinsic, and can then read the
argument, which is the callee's context. To prevent this, in functions that
write local 0, WebAssemblyExplicitLocals copies the swiftasync argument to
another local.
FastISel does not select loads and stores through the intrinsic, so that
SelectionDAG lowers them together with the intrinsic.
[MC] Remove write-only MCWasmStreamer::SeenIdent (NFC) (#245908)
The last reader was removed on May 2, 2018 in commit
4d57fbd02a8cb16045da65e078e72aa68e4ac21e. This patch also removes its
initializer and the now-redundant reset override.
Assisted-by: Antigravity
[AMDGPU] Remove write-only RegBankLegalizeRules::MRI (NFC) (#245907)
This patch teaches RegBankLegalizeRules to stop taking MRI. The rest of
the patch removes the code to plumb MRI into it.
Assisted-by: Antigravity
[LoopUtils] Check the first outer iteration for co-moving pointer groups
When runtime checks are hoisted out of the outer loop, the range of each
pointer group is widened to cover all iterations of the outer loop. If both
groups of a check advance by the same step in the outer loop, e.g. two rows
of the same image:
```cpp
for (y = 0; y < H; y += 2)
for (x = 0; x < n; x++) {
img[y*S + 3*x] = ...;
img[(y+1)*S + 3*x] = ...;
}
```
the widened ranges overlap as soon as the outer loop runs twice, so the
check always fails and the vector loop never runs.
If all bounds of both groups are affine AddRecs of the outer loop with the
[7 lines not shown]
[LoopUtils][LV] Compute runtime check bounds per check (NFCI)
getRuntimeCheckBounds takes a single pointer group, but the bounds to use
for one group can depend on the group it is checked against.
This changes RuntimePointerCheck to include bounds of both of its groups.
RuntimeCheckBounds takes the new role of covering both groups and
RuntimeCheckGroupBounds covering single group bounds.
The per-group logic moved unchanged into a static helper.
In VPlan's createRuntimeChecks, compute and expand the bounds of each check
right before its compares, in a single loop over the checks, instead of
caching the expanded bounds per group.
We can do it because VPSCEVExpander already reuses expansions of the same SCEV,
and VPlan's CSE merges the resulting duplicate freezes.
As the result, this change only affects the order of the instructions in
the runtime checks.
[LoopUtils] Factor out the same-step check of runtime check bounds (NFC)
The follow-up change uses four SCEV expressions for this type of change
so it also generalizes it to take an array.
[CIR] Use the pragma FP environment for __builtin_convertvector
`ScalarExprEmitter::VisitConvertVectorExpr` emitted the conversion
without a `CIRGenFPOptionsRAII`, so the cast got the floating-point
environment of the command line instead of the one that pragmas set at
the expression. With `-ffp-exception-behavior=strict` on the command
line and `#pragma clang fp exceptions(maytrap)` plus
`#pragma STDC FENV_ACCESS ON` in the function, ClangIR lowered the
conversions to constrained intrinsics with `round.tonearest` and
`fpexcept.strict`, where classic codegen emits `round.dynamic` and
`fpexcept.maytrap`.
Install the RAII for the conversion, after the source operand is
emitted, as classic codegen does on each floating-point path.
The test converts between float vectors and signed, unsigned, double
and bool vectors, so it covers the `float_to_bool` and `bool_to_float`
casts too. ClangIR and classic codegen share every LLVM check for them,
and the ClangIR run rejects any plain conversion or `fcmp` instruction
[7 lines not shown]
[SCEV] Treat expressions with use flags as maybe-poison. (#245980)
Use flags only hold where the expression is used, so an expression
carrying them, directly or in an operand, may be poison where it is
expanded. Return false from isGuaranteedNotToBePoison for such
expressions, consistent with impliesPoison.
This fixes a miscompile where SCEVExpander emitted a divisor with its
use flags in a block where they do not hold, turning the division into
immediate UB.
PR: https://github.com/llvm/llvm-project/pull/245980
[CIR] Keep complex and bool casts constrained in strict FP functions
In a strictfp function ClangIR emitted plain `fpext`, `fptrunc`,
`fptosi`, `sitofp`, `uitofp` and `fcmp une` for casts between complex
types and for conversions between floating-point values and bool, where
classic codegen emits constrained intrinsics. CIRGen created the
complex casts and `float_to_bool` without the `fenv` attribute,
LoweringPrepare dropped the attribute when it expanded a complex cast,
and the LLVM lowering of `float_to_bool` and `bool_to_float` ignored
it.
`createCast` now takes an optional `fenv` attribute. CIRGen passes the
current floating-point environment for `float_to_bool` and for the
complex cast kinds that convert floating-point values. The kinds that
only select or pack a part, `float_to_complex` and
`float_complex_to_real`, get none, and the verifier no longer accepts
the attribute on them. LoweringPrepare passes the attribute of a
complex cast to the scalar casts of its expansion. With `fenv`,
`float_to_bool` lowers to the quiet constrained `fcmp` and
[10 lines not shown]
[CIR] Handle integers wider than 64 bits in the vector constant folders
`cir::IntAttr::getUInt()` and `getSInt()` assert when the value needs
more than 64 bits. The folders of `cir.vec.cmp`, `cir.vec.ternary` and
`cir.vec.shuffle.dynamic` read constant elements through them, so they
asserted on a vector of `__int128` with such an element. C++ reaches
all three at -O0. The verifier of `cir.vec.shuffle` read its indices the
same way and asserted while parsing an index wider than 64 bits.
They now work on the `APInt` values:
- `cir.vec.cmp` compares the elements at their full width.
- `cir.vec.ternary` tests whether the condition element is zero.
- `cir.vec.shuffle.dynamic` masks the index before narrowing it.
- The `cir.vec.shuffle` verifier recognizes the -1 index by all of its
bits being set and range-checks the other indices without narrowing
them.
Folds of integers up to 64 bits are unchanged.
[2 lines not shown]
[CIR] Keep three-way comparisons constrained in strict FP functions
In a strictfp function ClangIR emitted plain `fcmp` for a three-way
comparison of floating-point values, where classic codegen emits
`llvm.experimental.constrained.fcmp`. `cir.cmp3way` had no `fenv`
attribute, and LoweringPrepare expanded it with a builder that has no
floating-point state.
This gives the operation the optional `fenv` attribute, valid only for
floating-point operands, and the fenv traits of the scalar operations
in place of `Pure`:
- CIRGen attaches the attribute. Like classic codegen it opens no
FP-options scope for the comparison itself, so the comparison takes
the environment in effect around it. In `return x <=> y` under
`FENV_ACCESS ON` alone that is the default of the function,
`fpexcept.ignore`.
- LoweringPrepare expands a comparison of floating-point values into
quiet `cir.fcmp`s, which take the attribute if the operation has one.
[10 lines not shown]