[AMDGPU] Classify generic-target features
Classify features used by generic targets but absent from some covered
GPUs as AMDGPUGenericAnyFeature. This covers the gfx11 workarounds,
gfx12.5 register fixup and WMMA timing, and LDS size and bank count.
Derive the classified features directly from the SubtargetFeature subclass
and preserve their existing predicates. Keep RequiresCOV6 outside this
policy because it is specific to generic targets and absent from their
covered GPUs.
Test the real target definitions, missing support for classified features,
and the existing all-member requirement for instruction capabilities.
Change-Id: I9fffbe532b8b5bc8875f20f394f29e2e6899f52e
[AMDGPU][NFC] Allow selected generic features on any covered GPU
Add AMDGPUGenericAnyFeature so individual feature classes can require
support from at least one covered GPU. Check explicitly marked features
even when they are not frontend-visible, while retaining the all-member
check for ordinary frontend-visible features.
Follow implied features using their own validation rules. Require named
generic targets to cover at least one concrete AMDGPU GPU, rejecting self
references, other generic targets, pseudo targets, and invalid members.
Cover partial support, missing support, exact numeric-feature membership,
backend-only features, implications, and malformed coverage lists with
TableGen tests. Generated target definitions remain unchanged.
[mlir][SparseTensor][NFC] Improve documentation for SparseTensor_LvlOp (#223307)
Update the `sparse_tensor.lvl` documentation to correctly describe the
level mapping for `%j floordiv 3`.
[clang-tidy] `use-ranges`: avoid unsafe result fix-its
Preserve callable results with .fun, allow structured-binding-safe rewrites, and keep diagnostics while suppressing unsafe fix-its when ranges result objects do not match the original result shape.
Assisted by Codex.
[clang-tidy] `use-ranges`: preserve output results
Preserve used output iterator results for output algorithm replacements by appending .out where the ranges algorithm returns an algorithm result object.
Fix #110223
Assisted by Codex.
[libc] Add macro / sysconf support for POSIX threads features. (#223543)
Define all `_POSIX_THREAD_*` macro and corresponding `_SC_THREAD_`
sysconf names that provide information on availability of certain
POSIX threads features.
* Explicitly provide all relevant macro from POSIX standard:
https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/unistd.h.html
to either 202405L (current POSIX version supported by LLVM-libc), or -1
(if the feature is unsupported)
* Support returning these features via `sysconf` for matching `_SC_`
name values;
* Add unit tests that validate the actual numerical values.
[flang][test][NFC] Re-add OpenMP test for mismatched loop bound types (#223876)
Lowering now materialises the literal at the loop variable's kind, so
there is a single i64 constant and no fir.convert. Updated the checks to
match and re-added the test.
[IR] Deprecate ConstantExpr::getSizeOf() and getAlignOf() (#223710)
These cannot be represented in terms of ptradd. They should be replaced
with plain constants with the size/alignment (based on DataLayout, or
direct frontend knowledge).
The C API wrappers `LLVMSizeOf()` and `LLVMAlignOf()` are deprecated for
the same reason.
The C APIs `LLVMBuildMalloc()` and `LLVMBuildArrayMalloc()` create a
constant with the size based on data layout now.
[LLVMABI] Narrow the eightbyte past a union's storage member (#223859)
`getIntegerTypeAtOffset` sized the eightbyte from the storage member the
union reduction picked, even at an offset that member does not reach. A
union whose second eightbyte holds one data byte then coerced to `i64`
where clang coerces to `i8`:
```c
union { char c[9]; void *p; };
```
Clang lowers it to `{ ptr, [8 x i8] }`, so that offset lands on padding
and the coercion narrows to a byte. The classifier now does the same,
and sizes the coercion from the union's remaining bytes otherwise.
Assisted-by: Cursor / claude-opus-5
[libc++] Optimize string::erase (#223721)
This change allows the `traits_type::move` (i.e. `memmove`) call to be
tail-called, removing the need for allocating any stack space and a
call. We also copy the null terminator through `memmove` instead of
inserting it manually.
[libc++] Take the mersenne twister ABI break unconditionally (#222700)
Technically this is ABI breaking, since we change the meaning of the
bytes inside the mersenne twister. However, this doesn't cause changes
in the size of any objects and is only an issue in very specific
circumstances. Specifically, the mersenne twister has to be passed on an
ABI boundary and be used on both sides of that ABI boundary. If it's
only used on one side, the values will continue to be correct, since
only a single algorithm is used. Even then, the only issue is that the
values aren't properly randomized, since both versions of the mersenne
twister implementation read the same type of data and produce the same
kind of output with it.
Fixes #209514
[cmake] Use the C++ linker when checking libxml2 (#221970)
When libxml2 is built statically with ICU support, its link interface
contains C++ libraries. `check_symbol_exists()` uses the C linker
driver, causing the libxml2 check to fail on unresolved C++ runtime
symbols and incorrectly report that `xmlReadMemory` is unavailable.
This issue was found in https://github.com/microsoft/vcpkg/pull/53727
[VPlan] Create VPSlotTracker's ModuleSlotTracker for the plan (NFC). (#223952)
Move the lazy creation of VPSlotTracker's ModuleSlotTracker into a new
getOrCreateMST helper, so it can be shared with other users in the
future (https://github.com/llvm/llvm-project/pull/203982).
Also get the function and module directly from the plan Create it for
the cached module and get the function to incorporate from the plan,
instead of using the module and function of the first unnamed
instruction printed.
PR: https://github.com/llvm/llvm-project/pull/223952
[clang-tidy] `use-ranges`: avoid unsafe result fix-its
Preserve callable results with .fun, allow structured-binding-safe rewrites, and keep diagnostics while suppressing unsafe fix-its when ranges result objects do not match the original result shape.
Assisted by Codex.
[clang-tidy] `use-ranges`: preserve output results
Preserve used output iterator results for output algorithm replacements by appending .out where the ranges algorithm returns an algorithm result object.
Fix #110223
Assisted by Codex.
[MLIR] Use false instead of nullptr for boolean args. (NFC) (#224009)
This fixes a build failure on macOS with -Werror:
error: implicit conversion of nullptr constant to 'bool'
[-Werror,-Wnull-conversion]
PR: https://github.com/llvm/llvm-project/pull/224009
[clang][OpenMP] Emit lastprivate final copies in no-loop kernels
Promotion rejected lastprivate because the no-loop branch leaves the
worksharing path before it privatizes or copies out, so the clause would
have been silently dropped.
Privatize the non-counter variables in the parallel region and copy them
out under the last iteration that applyWorkshareLoop publishes, forcing
the exit barrier the copy reads through. Loop counters stay at the
distribute level and reach EmitOMPSimdFinal.
[clang][OpenMP] Add no-loop SPMD kernel promotion
A target teams distribute parallel for that is guaranteed a thread for
every iteration does not need the loop around its body. Flang already
drops it and runs the region as a no-loop kernel.
Enable the same optimization for Clang through mirroring Flang's MLIR
promotion using OpenMPIRBuilder. The kernel is tagged SPMD_NO_LOOP, so
the runtime sizes the grid to the iteration space, and the body is
emitted without a loop around it. The canonical loop it consumes is
reconstructed in the no-loop branch rather than taken from an
OMPCanonicalLoop node, so the promotion does not require
-fopenmp-enable-irbuilder.
Restrict offload entry creation to module level finalize, preventing
asserts on missing offload entries from nested CodeGenFunction
finalizing before module completion.
[OpenMP] Honor barrier and last iteration flags in loop lowering
Emitting loop-free kernels for no-loop target regions in Clang requires
the shared OpenMP lowering to honor flags that reach it today and are
then discarded.
applyWorkshareLoop takes a NeedsBarrier flag, but the device path drops
it, so a worksharing loop without nowait emits no barrier at its exit.
The device path also never sets the canonical loop's last iteration
variable, which the linear clause finalization reads. Forward the flag
to applyWorkshareLoopTarget and compute the last iteration in the loop
body, mirroring how the host runtime reports it.
Auditing the surrounding lowering for the same class of problem turned
up one more. The barrier that follows privatization is emitted as part
of the firstprivate copy region, so a construct with lastprivate and no
firstprivate never gets one. Emit it independently of the copy region.
Flang skips it for taskloop, where the write-back already happens after
the reads.