[AMDGPU] Skip 32-bit addresses in SADDR fallback
Since #245220, SelectGlobalSAddr also accepts 32-bit (AS6) addresses.
The out-of-range offset fallback walked such an address before it was
extended, so a divergent AS6 load with a large constant failed with
"illegal VGPR to SGPR copy", and a wrapping 32-bit add could have been
split. Skip 32-bit addresses there and add a test.
Rename isUniformInVGPRs to isProducedInVGPRs: it asks where a uniform
value lives, not whether it is uniform. Update the async LDS tests for
the new s_wait_xcnt and the multicast mask clamp.
[AMDGPU] Support 'lds' as a normal named-bit modifier
b49855fc5684 made lds be parsed as a named bit, but in the asm
strings it remained a token, with parseCustomOperand() parsing it
with parseNamedBit() and validateTargetOperandClass() accepting
the resulting operand for the token. nolds was parsed and then
dropped without adding an operand.
This work-around is not needed. The modifier can be a normal
named-bit operand of the real instructions. The LDS DMA
instructions require it to be set and the buffer, global and
scratch loads that have LDS DMA variants accept nolds.
Side effects:
- nolds is now accepted on targets where the LDS DMA variants of
the loads are not available, e.g., buffer_load_dwordx4 before
gfx950 and global and scratch loads on gfx940+. lds is still
rejected there. This is consistent with nogds, which is
[20 lines not shown]
[mlir][LLVM] Export tbaa.struct metadata of memory intrinsics first (NFCI) (#248069)
The export of `llvm.intr.memcpy`, `llvm.intr.memmove` and
`llvm.intr.memcpy.inline` now sets `!tbaa.struct` before the access
group and alias metadata instead of after it. The call carries the same
metadata.
With this order the code of the intrinsic itself comes first and the
shared metadata code follows, as for every other intrinsic. #247481
relies on that to append the shared code in `LLVM_IntrOpBase`.
Assisted-by: Claude Code (Fable 5.2).
[AArch64] Implement ACLE intrinsics for FPv2 SVE min/max instructions
ACLE PR: https://github.com/ARM-software/acle/pull/480
Implements the following intrinsics:
- svmaxmg / svminmg
- svmaxinm / svmininm
- svmaxmginm / svminmginm
Includes f16, f32, and f64 types, _m, _z, and _x predication and _n variants
AI assistance: Codex used for generating test cases
[Clang-Repl] Introduce Error Recovery for Clang-Repl (#247062)
## Cross-PTU Mutation Tracking for clang-repl Error Recovery
### The problem
clang-repl compiles each input as a separate Partial Translation Unit
(PTU). If a PTU fails, we need to restore the AST to exactly how it was
before that PTU started.
Removing new declarations created by a failed PTU is easy. The harder
case is when a later PTU changes a declaration that was created by an
earlier PTU. These changes can happen indirectly as a side effect of
Clang, such as completing a class, instantiating a template, or
evaluating a constant.
So, for each declaration, we need to know which PTU changed each part of
its state and be able to undo only those changes.
[79 lines not shown]
[mlir][bufferization] Handle custom tensor memory space at function boundaries (#248055)
Building on top of #201350, which made `defaultMemorySpaceFn` and
`unknownTypeConverterFn` support tensor-like types, this PR removes the
restriction that `defaultMemorySpaceFn` is only queried for builtin
tensor types at function boundaries.
If `defaultMemorySpaceFn` returns `std::nullopt` for a custom tensor
type, an error is now emitted, as for builtin tensors.
Assisted-by: Claude Code
[PowerPC] Enable SlotIndexes compaction by default
Greedy measures live ranges in slot indexes, and instructions erased
before allocation (by PHI elimination, two-address lowering and the
coalescer) leave entries behind that make ranges look longer than
they are. Opt PowerPC in to dropping them, as AMDGPU and ARM do, so
allocation works with real distances. Passing
-greedy-compact-slot-indexes=false restores the old behaviour.
On CTMark (pwr8, pwr10, AIX, ppc32), .text and llc compile time move
by less than 0.03% and evictions drop by 1.5-5.8%.
The test updates are register allocation changes; csr-split.ll gets
back the live range split it was written to check.
[RISCV] Handle i1 any-of reductions with backedge as first operand in RISCVCodeGenPrepare (#247925)
In RISCVCodeGenPrepare we widen i1 vp.merges that are part of a
reduction to i8 since there's no tail undisturbed mask instructions. We
previously only allowed the backedge to be the first operand of the phi
though, but loop simplify can insert preheaders etc. that cause the
backedge to be the second operand.
[IfConversion] Fix edge probability of early-exit triangles
IfConvertTriangle() if-converts the triangle BB -> CvtMBB -> NextMBB,
BB -> NextMBB by predicating CvtMBB into BB. If CvtMBB has a second
successor, the early exit, the edge from BB to NextMBB should get the
combined probability of both paths to NextMBB. The code assumed that
this edge goes to getNextBlock(*BBI.BB), the block after BB in the
layout, and skipped the update if that block was not a successor. For
example, with the layout BB, CvtMBB, early exit, the merge moves CvtMBB
to the end of the function, so the early exit follows BB, but it is not
a successor yet. The edge to NextMBB then keeps the 100% it got when
CvtMBB was removed from the successors, and the edge to the early exit
is added on top, so the sum exceeds 100%. Look up NextMBB in the
successors of BB.
On ARM, this happens to a branch on a logical or that
SelectionDAGBuilder splits into two branches to the same cold block.
The block with the second branch is CvtMBB, the cold block is NextMBB,
and the hot block is the early exit. Both edges to the cold block are
[34 lines not shown]
[CIR] Run the offload passes on cir.offload.launch
cir-offload-merge -opt now runs
cir-offload-raise, mem2reg, cir-offload-sccp, symbol-dce,
launch bounds, pointer facts, cir-offload-lower
Launch argument propagation and dead kernel elimination are stock sccp and
symbol-dce on the linked container. Launch bounds and pointer facts read
the launches from cir.offload.launch and treat a nested kernel as closed.
KernelBindingTable, OffloadDeadKernelElimination and
OffloadKernelArgConstantPropagation are removed with their tests. The
remaining offload tests run between raise and lower and use the launch
shape CIRGen emits.
A HIP stub reads its kernel handle global. KernelBindingTable counted the
read as an escape, so no HIP kernel was closed. The raise pass accepts it
inside the stub, so HIP kernels now get argument propagation.
[4 lines not shown]
[clang] Use class availability for ObjC category members (#248047)
ObjC categories can extend classes beyond their original definition.
They inherit the availability of the class, and any additional
availability attributes on category members are merged with the class
availability. However, AvailabilityInfo directly walked to the
translation unit and skipped the class, leading to incorrect
availability in symbol graphs. Update this logic to walk from a category
to its class instead.
rdar://193865049
[CIR] Add cir-offload-raise, cir-offload-lower and cir-offload-sccp
cir-offload-raise turns a flat offload container into linked form and
rewrites each launch site in the shape CIRGen emits (push configuration,
cir.if, stub call) into cir.offload.launch. A site in any other shape is
left alone. A kernel gets nested visibility when its stub has local
linkage, every use of the stub is a raised launch, and no device code
refers to the kernel; the closed-world option turns this off. A kernel
with no stub and no device use is nested too.
With nested visibility, stock sccp propagates launch arguments into the
kernel and symbol-dce erases kernels that are never launched.
cir-offload-sccp runs sccp once per device module, each time with that
module's kernel as the launch callee, so every device module gets the
same propagation.
cir-offload-lower restores the flat container: raise followed by lower
gives back the input.
[libc++][pstl] Add serial implementations of in-place removal algorithms (#247591)
This PR adds serial implementations of in-place removal algorithms to
PSTL:
- `std::remove_if`
- `std::remove` (implemented in the `default` backend in terms of
`std::remove_if`)
- `std::unique`
Part #99938.
[CIR] Add cir.offload.launch and the linked offload container form
cir.offload.launch is a host-side kernel launch: the kernel in each device
module, the host stub, the dim3 grid and block, shared memory, stream and
kernel arguments. It implements CallOpInterface with the first kernel as
callee and only the kernel arguments as call operands, so stock
interprocedural passes see a launch as a call. The inliner never inlines
it.
A container with the cir.offload.linked attribute holds the host symbols
at its top level and only device modules nested, so a launch can refer
down to a kernel. The attribute keeps what is needed to restore the flat
form.
[mlir][tosa] Unify profile/extensions compliance checks (#247185)
This commits removes separate `checkProfile` and `checkExtension` APIs
and replaced them with a single `checkProfileOrExtension` in the
validation pass profile compliance. Not only does this simplify checks,
it also fixes compliance issues where knowledge of both profile and
extension requirements are needed at the same time to determine whether
an operation is invalid.
This is the case for int16 concat which is supported in the following
cases:
- when the int16 extension is available
- when the specification version is 1.1 and the selected profile is
pro_fp
Regression tests are added for the above case.
Assisted-by: Codex
[CIR] Keep symbols that symbol-dce cannot see the uses of
An appending global (llvm.used, llvm.compiler.used) and a global
constructor or destructor are live without any symbol use. symbol-dce
erased them once they were not public. Override canDiscardOnUseEmpty on
cir.global and cir.func to keep them.
[Clang][OpenMP] Use default address space for task and globalized pointers (#248200)
The pointer to a task descriptor returned by __kmpc_omp_task_alloc,
and the pointer to a variable globalized with __kmpc_alloc_shared,
were cast to address space 0. This is fine for some targets (AMDGPU,
NVPTX) but wrong for SPIR-V, where address space 0 is private memory
and the default is address space 4. The patch switches to the default
address space instead, which fixes SPIR-V and implies no change to the
currently-working targets.
I can't test this on hardware, but it resolves the SPIR-V compilation
crash revealed by #245784/#247569.
Assisted-By: Claude
[mlir][DataFlow] Resolve non-call symbol uses in their own symbol table
DeadCodeAnalysis::initializeSymbolCallables walks every nested symbol
table, but looked up the target of a non-call symbol use in `top`. A
reference nested in an inner symbol table did not resolve there, so the
address-taken callable was still treated as having only known callers and
SCCP propagated constants into its arguments.
Resolve the reference in the symbol table that holds the use.
[mlir][acc] Read 128-bit values in `acc.atomic.read` with `cmpxchg`
`acc.atomic.read` reads `x` with an `atomicrmw or` of zero on an integer
of the size of `x`. For a `complex<f64>`, that is an `i128`, which
the LLVM dialect verifier does not accept for integer operations of
`atomicrmw` ([LLVMMemoryOps.cpp#L509-L511][verifier]):
```mlir
acc.atomic.read %v = %x : !fir.ref<complex<f64>>, !fir.ref<complex<f64>>, complex<f64>
```
failed with:
```
'llvm.atomicrmw' op expected LLVM IR integer type
```
Read values wider than 64 bits with a `cmpxchg` of zero with zero
instead, and take the loaded value. It only stores zero where the value
[11 lines not shown]