Reapply "[libc++] Fix incorrect size check when growing std::string" (#234545) (#234551)
There was a race condition with another commit adding another call of
`__get_amortized_growth_capacity`. This is fixed in this version.
Original commit message:
When trying to grow very large amounts the `max_size()` check could fail
due to
the result of adding the current capacity and the additional capacity
could wrap.
This reverts commit 64b40b84eb293e259cfe36add2ac34ab3dafc05c.
[Offload][Omp] Remove usages of GenericDeviceTy (#236340)
Remove all simple direct usages of GenericDeviceTy. In most cases
replace with equivalents from liboffload itself.
For RecordReplay, access it through a helper in liboffload. This will
allow to eventually remove completely GenericDeviceTy from the
libomptarget structures.
Assisted by Claude.
[mlir][spirv-to-llvm] Add conversion for spirv.CopyMemory (#232944)
Convert `spirv.CopyMemory` to `llvm.intr.memcpy`. The byte size copied
is computed from the converted pointee type using the module's data
layout (`DataLayout::closest(op).getTypeSize(...)`) and passed as an
`i64` constant. Runtime arrays (converted to 0-element LLVM arrays) and
scalable types have no fixed static size and fail to match.
Memory-access operands follow the SPIR-V 1.4 specification: when only a
single mask is present it applies to both Target and Source, and when a
second mask is present it applies to Source while the first applies to
Target.
[SPIRV] Lower constant-count entry-block allocas without VLA (#232579)
`alloca T, N` with a constant N in the entry block is a fixed-size
allocation, but it was lowered through the variable-length array path
and required SPV_INTEL_variable_length_array. Rewrite it to `alloca [N x
T]` before pointer type inference so it becomes a plain OpVariable, as
InstCombine already does at -O1+.
[clang] Replace PointerUnion::dyn_cast with llvm::dyn_cast (NFC) (#236317)
PointerUnion::dyn_cast has been soft-deprecated in favor of
llvm::dyn_cast and llvm::dyn_cast_if_present. This patch replaces
PointerUnion::dyn_cast with llvm::dyn_cast in
MatcherContext::Query::get.
Note that IRMatchers.h is only used by TBAAMetadataTest.cpp, where
MatcherContext::Query::Entity is always initialized with nonnull
pointers and never modified afterward.
Assisted-by: Antigravity
[llvm] Remove unused type aliases in .cpp files (NFC) (#236318)
This patch removes unused using and typedef type aliases across .cpp
files under llvm/.
Note that none of the aliased types are spelled out in their
respective .cpp files, so these aliases have no potential use sites in
those files.
Assisted-by: Antigravity
[Clang][ABI][X86] Don't return _BitInt as {i64, i64} (#236112)
`_BitInt(N)` for N <= 64 gets returned as `iN`, while for 64 < N < 128
it's returned as `{i64, i64}`, before it becomes `i128` again for N=128.
This changes the ABI code to always use `iN` for N <= 128 (larger types
get passed in memory, not directly).
This doesn't change the actual ABI (returned as two registers, high bits
unspecified), just simplifies how it is represented in IR.
Worth noting that the case of `_BitInt` inside a struct currently
produces different results between Clang and the ABI library. I will
address this in a followup. The argument case will also be handled
separately.
This is a followup to https://github.com/llvm/llvm-project/pull/234872,
which handled the N < 64 case.
[ValueTypes] Implement `getEVTString` in terms of `print` (#236276)
Many calls need to allocate, so add a version that doesn't require this
and use it in places where streams are already used.
[Clang] use `SubstConstraintExpr` instead of `SubstExpr` in `Sema::BuildExprRequirement` (#236286)
This fixed a regression introduced since the last rewrite of concepts, mirroring 24df1d13d9090e075b162bf81d1a34a408e54924.
[X86] Add _MM_FROUND_TO_NEAREST_TIES_EVEN clang codegen test coverage (#202063)
The static rounding mode for X86 intrinsics that produce floating-point
results should use the macro `_MM_FROUND_TO_NEAREST_TIES_EVEN` rather
than `MM_FROUND_TO_NEAREST_INT`.
See also:
https://github.com/llvm/llvm-project/pull/99691#issuecomment-2245842818
[libc][math] Implement double precision cosh correctly rounded to all rounding modes. (#235181)
Use shared `exp(x) +- exp(-x)` evaluations with `sinh` from
https://github.com/llvm/llvm-project/pull/235097.
Assisted-by: Gemini for analysis and refactoring.
[libc][math] Implement double precision sinh correctly rounded for all rounding modes. (#235097)
- Extend even/odd polynomial evalutions of exp(x) +- exp(-x) from single
precision to double-double and 128-bit fixed point.
- Optimize range reduction using the trick from previous exp
implementation, combining with the new fp-bitwise operations, and
reapply it to exp and exp2.
Assisted-by: Gemini for analysis and refactoring.
[LV] Don't introduce UB when rewriting SCEVs with versioned strides. (#236313)
replaceSymbolicStrides rewrites the SCEVs of VPExpandSCEVRecipes in the
entry block using the versioned strides (e.g. Stride == 1). Those
expressions are expanded before the SCEV checks that guarantee the
predicates, so the rewritten expressions must not introduce UB when the
predicates do not hold. For example, the trip count n /u (stride + y)
was rewritten to n /u (y + 1), which divides by zero for y == -1 and
stride != 1, while the original loop is well defined.