[OpenMP][omptest] Run the ompTest unit tests on the AMDGPU clang-flang bot
ompTest ships unit tests that register as check-ompt-omptest, but
LIBOMPTEST_BUILD_UNITTESTS defaults to OFF, so no buildbot builds or runs
them. Its install rules are likewise never exercised.
Enable both on the openmp-offload-amdgpu-clang-flang bot, which already runs
check-openmp and installs.
Assisted-by: Claude Opus 5 <noreply at anthropic.com>
[OpenMP][omptest] Configure installed header (#237201)
Install a configured header to carry configure-time settings into the libomptest installation to allow consumers to take decision.
Important for consumers to know if they can rely on certain features being present, e.g., GoogleTest macros vs omptest standablone build.
AI-assisted by: Claude Opus-5.5
[Clang][OpenMP] Add flatten empty-loop final value tests (#237907)
Flatten used to always run inner inits like J = 0 before the loop.
Finals already skip leftover writes when a loop has no trips, so that
PreInit value stuck and leftover J was wrong. In simple words, Flatten
was setting inner loop vars even when the outer loop never ran.
This patch adds tests for the fix already made.
#225350
[GlobalISel] Narrow G_FREEZE with a leftover piece
When narrowing G_FREEZE (and G_CONSTANT_FOLD_BARRIER) to a type that
doesn't evenly divide the original, split into NarrowTy pieces plus a
leftover piece instead of giving up.
Co-authored-by: Cursor <cursoragent at cursor.com>
[mlir][bufferization] Accept buffer-like operands in dealloc and clone (#245354)
`bufferization.dealloc` and `bufferization.clone` currently accept only
`memref` operands. This PR relaxes their operand and result types to
`BufferLikeTypeInterface`. The only IR this changes is what the verifier
accepts. The lowerings to the `memref` dialect,
`BufferOriginAnalysis::isSameAllocation` and `CloneOp::buildDealloc` now
decline a non-`memref` instead of asserting or building invalid IR.
Lowering of `memref`-typed operands is unchanged.
Test that `bufferization.dealloc` and `bufferization.clone` can accept
`BufferLikeTypeInterface` operands, but that lowering to `memref`
dialect refuses operands which are not `memref`.
This is the first in a series of PRs that intends to generalize
`bufferization` dialect and its passes to accept buffer types other than
`memref`.
Assisted-by: Claude
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[wasm] Swift async ABI p3: Lower llvm.swift.async.context.addr to local 0
With this commit, in functions with a swiftasync argument, the async
context intrinsic is lowered to local 0. Without a swiftasync argument,
the intrinsic is a stack slot, as on X86 without an extended frame.
Loads and stores through llvm.swift.async.context.addr become local.get 0
and local.set 0. Other uses of the address are an error, because locals
have no address.
The swiftasync argument also arrives in local 0, so the argument and the
intrinsic are two names for the same location. After a write through one of
them, a read through the other returns the wrong value. Await resume funclets
write their own context through the intrinsic, and can then read the
argument, which is the callee's context. To prevent this, in functions that
write local 0, WebAssemblyExplicitLocals copies the swiftasync argument to
another local.
[mlir][bufferization] Read alloc_tensor copy extents only from a memref (#245090)
`populateDynamicDimSizes` can read the extents of `alloc_tensor`'s copy
buffer only when the copy buffer is a `memref`. Check that precondition
in `AllocTensorOpInterface::bufferize` before calling. Otherwise,
`populateDynamicDimSizes` will crash if a non-`memref` reaches this
path.
Also test that non-`memref` copy operands to
`bufferization.alloc_tensor` with a dynamic extent print a diagnostic
instead of crashing.
Assisted-by: Claude
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
Add new section to Building.md
Removed the now-ignored option from the bootstrap-build config example.
Created a new section dedicated to omptest and how to make it
installable.
[libc++] Remove redundant _LIBCPP_HIDE_FROM_ABI from public headers (#246188)
This is the sixth bulk-removal patch of `_LIBCPP_HIDE_FROM_ABI`. While
this is something we could do over time, actively removing the redundant
annotations significantly improves readability, and QoI.
This happens in a few patches to keep the size somewhat manageable.
[AArch64] Sink expressions that can form DEC/INC Z instrucitons
Sinking of the whole "scaled vscale splat" chain is necessary for SDAG
to select it to DEC/INC instuctions. This can help reduce ZPR register
pressure. Previously, the splats had to stay live throughout the whole
loop, or loop nest.
Assisted-by: codex (test creation)
[AMDGPU] Fold constant scale of exp2/pow into the exponent (#243079)
[AMDGPU] Fold constant scale of exp2/exp/pow into the exponent
Fold a constant multiply of an exp2, exp or pow result into the
exponent, so it merges with the existing multiply as an fma:
fmul (fexp2 (fmul a, b)), C -> fexp2 (fma a, b, log2(C))
fmul (fexp x), C -> fexp2 (fma x, log2(e), log2(C))
fmul (fpow x, Y), C -> exp (fma (log x), Y, log2(C))
This removes the trailing v_mul_f32 after v_exp_f32.
Requires f32, reassoc+afn, a one-use exp (and a one-use inner fmul for
exp2), a positive normal C, a VOP3 literal (gfx10+), and contract on the
multiply the fma replaces. For pow, IEEE fma is used only when Y is a
normal constant; otherwise v_fma_legacy (gfx10.3+) preserves the 0*inf=0
behaviour of lowerFPOW. Keep fexp2 so IEEE denormal handling still runs.
Drop ninf on the pow expansion so log2(0) = -inf is not treated as
[2 lines not shown]
[Mips] Accept the register forms of mul before MIPS32 (#245741)
Before MIPS32 there is no mul instruction, so the integrated assembler
rejected mul rd, rs, rt and mul rd, rs on MIPS I to MIPS V, although it
already expanded mul rd, rs, imm. GAS expands the register forms to
multu and mflo. Do the same, as is already done for dmul.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[RISCV] Fix RVV callee-saves in realigned frames
The prologue saves RVV callee-saved registers before it realigns SP
and sets up BP, but their slots were addressed from the realigned SP
or BP. The epilogue reloaded them from the wrong address, BP frames
stored them through the caller's s1, and their CFI was wrong.
Address these slots from FP, which does not move, and derive their
CFI from getFrameIndexReference so the two cannot diverge.
Fixes #244792
[RISCV] Add tests for RVV CSRs in realigned frames
Precommit the tests for #244792 so that its fix shows up as a diff.
The checks record the current, wrong output: the prologue saves the
vector callee-saved registers before it realigns the stack, and the
epilogue reloads them from a different address.
[Mips] Use libcalls for atomic operations on MIPS I (#124218)
MIPS I has no ll and sc, but the maximum atomic size was 32 bits for
every 32-bit subtarget other than the R5900, so atomic operations on
MIPS I were expanded into ll/sc loops. Set it to 0 on MIPS I, as is
already done for the R5900, so they become __atomic_* libcalls.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[GlobalISel] Narrow G_FREEZE with a leftover piece
When narrowing G_FREEZE (and G_CONSTANT_FOLD_BARRIER) to a type that
doesn't evenly divide the original, split into NarrowTy pieces plus a
leftover piece instead of giving up.
Co-authored-by: Cursor <cursoragent at cursor.com>
[AMDGPU][GlobalISel] Legalize G_MERGE_VALUES/G_UNMERGE_VALUES wider than max scalar
Treat a merge/unmerge whose combined type is wider than the largest
scalar as legal when each piece is already a legal register type.
Co-authored-by: Cursor <cursoragent at cursor.com>
[AMDGPU][GlobalISel] Legalize G_CONCAT_VECTORS wider than the largest register
Treat a G_CONCAT_VECTORS whose result is wider than the largest register
class as legal provided it is built from already-legal vector pieces.
Co-authored-by: Cursor <cursoragent at cursor.com>
[AMDGPU][GlobalISel] Fix ds_append/ds_consume addressing
This matches the SelectionDAG fix. For LDS, ds_append and ds_consume
address memory only through the 16 bit instruction offset and ignore
M0, but the selector copied the pointer base into M0. Select a constant,
dword aligned LDS address into the offset field and diagnose any other
LDS address as unsupported.
For GDS, the offset field must be zero and the address comes from
M0.base, so build M0 as `(addr << 16) | gds_size`. Using GDS on a
subtarget without GDS is now diagnosed.
```
; call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) inttoptr (i32 16 to ptr addrspace(3)), i1 false)
; before
s_mov_b32 m0, 16
ds_append v0
; after
ds_append v0 offset:16
```
[AMDGPU] Fix ds_append/ds_consume addressing in SelectionDAG
For LDS, ds_append and ds_consume address memory only through the 16 bit
instruction offset. M0 is not used, but isel put the pointer (or its
base) into M0, so the counter was read at the wrong address. Select a
constant, dword aligned LDS address into the offset field and diagnose
any other LDS address as unsupported.
For GDS, the ISA requires the offset field to be zero and takes the
address from M0.base, so pack the whole address into M0 as
`(addr << 16) | gds_size`. Using GDS on a subtarget without GDS is now
diagnosed instead of silently encoding a GDS bit.
```
; call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) inttoptr (i32 16 to ptr addrspace(3)), i1 false)
; before
s_mov_b32 m0, 16
ds_append v0
; after
[4 lines not shown]
[AMDGPU] Stop sinking addresses into ds_append/ds_consume
ds_append and ds_consume have no address register operand. For LDS the
address comes only from the 16 bit offset field, and M0 is not used. The
register plus immediate DS addressing mode reported through
getAddrModeArguments does not apply, so CodeGenPrepare should not sink
address computations into these intrinsics.
```llvm
entry:
%in.gep = getelementptr i32, ptr addrspace(3) %in, i32 7
br i1 %cond, label %endif, label %if
if:
%val = call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) %in.gep, i1 false)
; before: CodeGenPrepare sinks the address into %if
%sunkaddr = getelementptr i8, ptr addrspace(3) %in, i32 28
%val = call i32 @llvm.amdgcn.ds.append.p3(ptr addrspace(3) %sunkaddr, i1 false)
; after: the call keeps using %in.gep
[5 lines not shown]
[AMDGPU][GlobalISel] Legalize G_BUILD_VECTOR wider than the largest register
Treat a G_BUILD_VECTOR whose result is wider than the largest register
class as legal provided it is built from already-legal scalar elements.
Co-authored-by: Cursor <cursoragent at cursor.com>
[AMDGPU] Use constant LDS addresses in ds_append/ds_consume tests. NFC (#245229)
LDS ds_append/ds_consume ignore M0 and take the whole address from the
16 bit offset field, so only constant LDS addresses can be encoded.
Switch the LDS cases to constant addresses, drop the dynamic LDS
address cases, add gfx11 RUN lines, split the SDAG and GlobalISel
prefixes and autogenerate the checks. GDS cases now set
"amdgpu-gds-size" so the M0 size field is covered.
This records the current wrong output. LDS puts the address in M0
instead of the offset field. GDS puts the raw address in M0 instead of
`(addr << 16) | gds_size`.
```
; ds.append.p3(ptr addrspace(3) inttoptr (i32 16 to ptr addrspace(3)))
s_mov_b32 m0, 16
ds_append v0
; ds.append.p2(ptr addrspace(2) inttoptr (i32 16 to ptr addrspace(2)))
[7 lines not shown]
[AMDGPU][GlobalISel] Legalize G_IMPLICIT_DEF of vectors of wide elements
Scalarize G_IMPLICIT_DEF of vectors whose elements are wider than the
clamps assume (e.g. <2 x s1024>), so each element is legalized
independently.
Co-authored-by: Cursor <cursoragent at cursor.com>