[clang][ssaf] Implement Entity Linker CLI and patching for JSON Format
This PR implements Entity ID patching for the JSON serialization format
and introduces `ssaf-linker`, a command-line tool that drives the
`EntityLinker`.
1. Entity ID references inside summary blobs use the sentinel
representation `{"@": <uint64>}`. Patching walks the JSON value tree
recursively, recognizes sentinels, and rewrites their indices using the
`EntityResolutionTable` provided by the linker.
2. An object with an `@` key but extra keys `(size != 1)`, an `@` value
that is not a valid `uint64`, and an entity ID not present in the
resolution table, lead to patching errors.
3. `JSONFormat::EntityIdConverter` is replaced with two `function_ref`
typedefs to eliminate the wrapper class.
4.`ssaf-linker` is implemented in `clang/tools/ssaf-linker/` and gets
built at `bin/ssaf-linker`.
5. lit tests check CLI, verbose output, timing output, validation
errors, I/O errors, linking errors, and successful linking.
rdar://162570931
[mlir][OpenACC] Normalize loop bounds in convertACCLoopToSCFFor for negative steps (#184935)
`convertACCLoopToSCFFor` was passing `acc.loop` bounds directly to
`scf.for`, which produces an `scf.for` with a negative step when the
source is a Fortran DO loop counting down (e.g. `DO k = n, 1, -1`).
Since `scf.for` requires a positive step, this generated invalid IR that
caused downstream crashes during LLVM lowering.
`convertACCLoopToSCFParallel` already normalizes all loops
unconditionally to `lb=0, step=1, ub=tripCount`, but
`convertACCLoopToSCFFor` did not. This patch applies the same
normalization to `convertACCLoopToSCFFor`, with IV denormalization in
the loop body (`original_iv = normalized_iv * orig_step + orig_lb`), and
lets later passes fold away constants.
[libc] Use unsigned char in strcmp, strncmp, and strcoll comparisons (#185393)
According to section 7.24.1 of the C standard, character comparison in
string functions must be performed as if the characters had the type
`unsigned char`.
The previous implementations of `strcmp`, `strncmp`, and `strcoll` were
doing a direct subtraction of `char` values. On platforms where `char`
is signed, this resulted in incorrect negative values being returned
when characters exceeding 127 were being compared.
This patch fixes the comparison functions to explicitly cast the
character values to `unsigned char` prior to computing their difference.
It also adds regression tests to ensure the comparison behaves correctly
for ASCII values greater than 127.
AMDGPU: Annotate group size ABI loads with range metadata (#185420)
We previously did the same for the grid size when annotated.
The group size is easier, so it's weird that this wasn't implemented
first.
[HLSL][Matrix] Make HLSLElementwiseCast respect matrix memory layout (#184429)
Fixes #184379
Changes the implementation of HLSLElementwiseCast to respect matrix
memory layout.
The new implementation reads from the `LoadList` array in row-major
order as opposed to column-major in the old implementation, which makes
more sense because `LoadList` is always interpreted in row-major order
when read as a matrix.
The writes to the allocation `V` for the destination matrix now respects
the default matrix memory layout.
Assisted-by: claude-opus-4.6
[CIR] Fix try_call replacement for indirect calls (#185095)
We had a bug in the FlattenCFG pass where if an indirect call occurred
within a cleanup scope that required exception handling, the indirect
callee was not being preserved in the cir.try_call. This fixes that.
[CIR][AArch64] Add lowering for remaining `vabd_*` builtins
Implement the missing CIR lowerings for the AdvSIMD (Neon) `vabd_*`
(absolute difference) intrinsic group.
Most `vabd` variants were already supported (see #183595); this patch
completes the remaining cases listed in [1].
Move the corresponding tests from:
* clang/test/CodeGen/AArch64/neon_intrinsics.c
to:
* clang/test/CodeGen/AArch64/neon/intrinsics.c
The implementation mirrors the existing lowering in
CodeGen/TargetBuiltins/ARM.cpp. To support this, add the
`emitCommonNeonSISDBuiltinExpr` helper.
Reference:
[1] https://arm-software.github.io/acle/neon_intrinsics/advsimd.html#absolute-difference
[TableGen] Add let append/prepend syntax for field concatenation (#182382)
## Motivation
LLVM TableGen currently lacks a way to **accumulate** field values
across class hierarchies. When a derived class sets a field via `let`,
it completely replaces the parent's value. This forces users into
verbose workarounds like:
```tablegen
class Op { // This is generic MLIR Base
code extraClassDeclaration = ?;
}
// Some Generic shared base
class MyShared1OpClass : Op {
code shared1ExtraClassDeclaration = [{ some generic code 1 }];
}
[157 lines not shown]
[PowerPC] Add AMO load with Compare and Swap Not Equal (#178061)
This commit adds support for lwat/ldat atomic operations with function
code 16 (Compare and Swap Not Equal) via 4 clang builtins:
__builtin_amo_lwat_csne for 32-bit unsigned operations
__builtin_amo_ldat_csne for 64-bit unsigned operations
__builtin_amo_lwat_csne_s for 32-bit signed operations
__builtin_amo_ldat_csne_s for 64-bit signed operations
[LLDB] Remove C++ language runtime dependency of Clang expression parser (#185450)
From
https://github.com/llvm/llvm-project/pull/169225#issuecomment-4024377289:
There was a dependency cycle involving the C++ language runtime:
```
//lldb/source/Plugins/TypeSystem/Clang:Clang ->
//lldb/source/Plugins/ExpressionParser/Clang:Clang ->
//lldb/source/Plugins/LanguageRuntime/CPlusPlus:CPlusPlus ->
//lldb/source/Plugins/TypeSystem/Clang:Clang
```
`ExpressionParserClang` doesn't need to depend on the C++ language
runtime. It only included a file, but didn't use it. This PR removes
that dependency.
[GOFF] Set reference to ADA (#179734)
Function symbols must have a reference to the ADA, because this becomes
the value of the r5 register when the function is called. Simply get the
value from the begin symbol of the section.
[clang-doc] Cleanup CMake files and ensure benchmarks build
There's some poor formatting, and ClangDocBenchmark references several
targets that are required, but only because they're required for
clang-doc itself. We can just get those requirements from the clangDoc
target.
Additionally, we can make sure the benchmark builds as part of testing
when LLVM_INCLUDE_BENCHMARKS is set.
[CIR] Extract CIR_VAOp base class for VAStartOp and VAEndOp (#185258)
Both ops share identical arguments and assembly format. Extract a common
base class to eliminate the duplication.
[TableGen] Fix ordering of register classes with artificial members. (#185448)
The current implementation wouldn't advance IB to skip artificial
registers once IA has reached the end.
[MTE] [HWASan] do not remove lifetimes for unterminated lifetime
The reasoning for this was incorrect. Return is an implicit lifetime
end of all allocas, so we are not inserting outside of a lifetime.
Reviewers: pcc, usama54321
Reviewed By: pcc
Pull Request: https://github.com/llvm/llvm-project/pull/184387
[mlir][tosa][tosa-to-linalg] Fix resize bilinear delta computation for negative offsets (#184799)
Use floor-consistent remainder when lowering floating-point tosa.resize
to linalg: compute `r = in - floor(in/scale_n)*scale_n` instead of
RemSIOp. This keeps bilinear deltas in-range for negative offsets and
avoids invalid interpolation weights.
[CIR] Fix spurious MemRead on pure pointer-arithmetic ops (#185154)
Remove incorrect [MemRead] annotations from seven CIR ops that only
perform pointer arithmetic, and add the Pure trait where missing.
- VTableGetVPtrOp computes the address of the vptr slot within an
object. Since the vptr is always at offset zero, this is a bitcast —
confirmed by the lowering which does replaceOp(op, srcVal). No memory
access.
- VTableGetVirtualFnAddrOp takes an already-loaded !cir.vptr value and
an index, computes the address of the nth vtable entry. Lowers to a
GEPOp. No memory access.
- VTableGetTypeInfoOp takes an already-loaded !cir.vptr value, computes
the address of the type_info entry at a known ABI offset. Pointer
arithmetic only. No memory access.
- GetMemberOp computes the address of a struct/class member given a base
[16 lines not shown]
[libc++] Use compiler explorer for Clang as well and update to LLVM 23 as head (#185168)
Using the compiler explorer infrastucture simplifies the dockerfile a
bit, since we have a single source for compilers now instead of two
independent ones. compiler explorer is also usually significantly faster
at providing new versions than apt.llvm.org.
[mlir][Linalg] Prevent vectorization of generic Conv with dynamic dims (#185415)
-- We should use `isaConvolutionOpInterface` instead as it accommodates
both named as well as generic convolution ops.
-- https://github.com/llvm/llvm-project/pull/176339 missed making one
such update to `vectorizeDynamicLinalgOpPrecondition` and it got exposed
in a downstream project.
-- This commit therefore aims to fix the same.
Signed-off-by: Abhishek Varma <abhvarma at amd.com>
[mlir][vector] Flatten transfer - support multi-dim scalar element (#185417)
Adds support for flattening multi-dimensional scalar vector transfers.
The addition prevents pattern crashes on such inputs and allows for
cleaner lowering of scalar vectors.