[OpenMP][Clang] Fix parsing of num_teams lower-bound modifier (#205700)
PR #180608 added parsing for the `lower-bound` modifier in the
`num_teams` clause. However, the lower bound expression is handled by
adding it to the first position of the clause's varlist, which is the
list that holds the number of teams for each dimension when `ompx_bare`
is specified. Given that the interpretation of the varlist depends on
its length, the following `ompx_bare` cases are broken:
- `#pragma omp target teams ompx_bare num_teams(11,10)` is interpreted
as a lower-bound and upper-bound, triggering the error "_lower bound is
greater than upper bound in 'num_teams' clause_".
- `#pragma omp target teams ompx_bare num_teams(1,2)` is interpreted as
`num_teams(1:2)` when printing the AST.
This commit fixes the collision by storing the lower bound separated from
the list of upper-bounds. This change is necessary for landing the
upcoming support for multidimensional team spaces (OpenMP 6.1) through
the `dims` modifier.
[VPlan] Support SRem in getSCEVExprForVPValue. (#206361)
Extend vputils::getSCEVExprForVPValue to construct SCEV expressions for
SRem recipes. A SRem of non-negative operands is equivalent to URem.
Enables SCEV-based no-alias reasoning for stores derived from SRem GEPs.
[llubi] Treat `llvm.experimental.noalias.scope.decl` as a noop (#206357)
The noalias support is still work in progress:
https://github.com/llvm/llvm-project/pull/195808
`llvm.experimental.noalias.scope.decl` is emitted by the inliner. We may
need more time to clarify the semantics.
This patch treats the intrinsic as a noop to avoid crashes (metadata
arguments are not supported before this patch).
[InstCombine] Create new instructions instead of in-place operand replacement (#115988)
Fixes https://github.com/llvm/llvm-project/issues/115890.
Currently it doesn't affect final codegen. But we may suffer from this
problem when we utilize these attributes for further optimization (e.g.,
https://github.com/llvm/llvm-project/pull/111284). This test case is
reduced from a csmith-generated C program. And I believe this problem
also exists in real-world programs.
[SmallPtrSet] Optimize Grow and inline FindBucketFor. NFC (#206304)
During rehashing every key is known absent, so skip the equal-key
comparison.
DenseMap got a similar optimization in #200595
FindBucketFor is then only used by insert_imp_big; inline its probe loop
there. The loop takes 7 inst instead of 9 in the clang-generated
assembly after removing the two `LLVM_LIKELY`.
[LV] Add test with pointer based on SRem expression (NFC). (#206344)
Add a test with loads and stores with pointers based on a signed
remainder (srem) of a non-negative induction variable, mirroring the
existing urem test.
[SLP][NFC] Avoid undef usage in odd_store.ll (#206333)
Replace `ret i32 undef` with void return type to avoid CI undef
deprecator failures.
For this PR: https://github.com/llvm/llvm-project/pull/206259
[clang] builtins for atomicrmw fminmax/_num (#187139)
Adds compiler builtins for `atomicrmw`: `fminimum`, `fmaximum`,
`fminimum_num`, `fmaximum_num`.
These will be used by the corresponding libc++ atomic apis (see #186716).
[libc][test] Build LibcFPTestHelpers in full-build mode
In a full build the unit framework is built in overlay mode while the tests
use LIBC_FULL_BUILD, so FEnvSafeTest's fenv_t member differs in size (16 vs
8 bytes on Darwin) -- an ODR violation that crashes math smoke tests. Add a
UNIT_AS_FULL_BUILD opt-in and use it for the hermetic LibcFPTestHelpers.
[libc][math] Fix aarch64 Darwin fenv implementation for full builds
A full build replaces the system (Apple) <fenv.h> with libc's headers, so
fenv_darwin_impl.h no longer found an 8-byte fenv_t, FE_FLUSHTOZERO, or the
__fpcr_* masks it relied on. Size FPState to the fenv_t in scope, alias
FE_FLUSHTOZERO to FE_DENORM, and define the FPCR trap masks locally.
[libc][math] Extend iscanonical macro to _Float16 and float128
iscanonical is a C23 type-generic macro, so the f16/f128 variants are
surfaced through it rather than as functions in the generated math.h.
float128 is only listed when distinct from long double (LDBL_MANT_DIG !=
113) to avoid two _Generic associations with compatible types.
[libc++][test] Drop _BitInt(96) byteswap padding check on 32-bit x86 (#205295)
`byteswap.verify.cpp` (added in #203876) expects `std::byteswap(unsigned
_BitInt(96))` to be rejected for having padding bits. That holds on
x86_64, where the type is 16 bytes with 32 padding bits, but not on
32-bit x86: the i386 psABI aligns `_BitInt` to 4 bytes and packs
`_BitInt(96)` into 12 bytes with no padding, so the call is well-formed
and the expected diagnostic never fires. The Android i386 builder caught
this.
Gate `test_unsigned_96` on `!defined(__i386__)`. Every other target,
including 32-bit arm, riscv32, ppc32, mips32 and sparc32, gives
`_BitInt(96)` 16 bytes with padding, so the case still exercises the
padding-bit Mandate everywhere except 32-bit x86. `sizeof` is not
available to the preprocessor, so the guard is a target check rather
than a direct has-padding predicate.
Assisted-by: Claude (Anthropic)
[2 lines not shown]
[clang-tidy] Move part of bugprone-unhandled-code-paths to a new check readability-trivial-switch (#198237)
The moved part detects trivial `switch` statement which can be removed
or rewritted as `if` statement.
hicpp-multiway-paths-covered was removed without keeping its name as
alias, so we don't need to update infrastructore to support one-to-many
aliases.
Changes were generated by AI, and reviewed and modified by me
afterwards.
Assisted-by: GPT-5.5
[clang] Replace Sema::OffsetOfComponent with Designation (#199097)
The parser previously fed __builtin_offsetof through a small ad-hoc
struct (Sema::OffsetOfComponent) that mirrors the same path data already
modeled by Designation/Designator. With the recent code-completion work,
the parser was building both shapes side by side.
Drop OffsetOfComponent. ActOnBuiltinOffsetOf, BuildBuiltinOffsetOf, and
TreeTransform::RebuildOffsetOfExpr now take a const Designation &.
- Parser: stops maintaining the parallel Comps vector and feeds the
Designation it already collected for completion straight to Sema.
- BuildBuiltinOffsetOf: iterates over the Designation.
- TreeTransform: rebuilds a Designation from each OffsetOfNode. The AST
node already encodes "leading-dot collapsed to name location" via its
Range constructor, so we mirror that by passing an empty DotLoc whenever
the new Designation is still empty.
- OffsetOfNode: tighten the identifier constructor and getFieldName
accessor to const IdentifierInfo*, matching Designator's accessor and
[9 lines not shown]
[InstSimplify] Fold splice.right(splice.left(poison, x, offset), poison, offset) -> x (#204256)
Fixes #203027
Adds an InstSimplify fold for
llvm.vector.splice.left/m.vector.splice.right roundtrip. The values in a
vector are first shifted to the right and then to the left, filling the
clipped off values with poison. In this scenario, the shift operations
get simplified to just x.