[CIR] Add support for atomic fmaximum/fminimum/fmaximumnum/fminimumnum (#211845)
This patch adds CIR support for the following atomic builtin functions:
- `__atomic_fetch_fmaximum`
- `__atomic_fetch_fminimum`
- `__atomic_fetch_fmaximumnum`
- `__atomic_fetch_fminimumnum`
The scoped versions of these atomic builtin functions are supported as
well.
Specifically, this patch contains the following changes:
- It updates the `cir.atomic.fetch` operation and adds new fetch
operators including `maximum`, `minimum`, `maximumnum`, and
`minimumnum`. These operators accept floating-point inputs only.
- It updates the LLVM lowering of the `cir.atomic.fetch` operation. The
LLVM lowering now will lower `maximum`, `minimum`, `maximumnum`, and
[6 lines not shown]
[MLIR][Python] Support IsIsolatedFromAbove trait for python-defined operations (#211849)
This PR adds dynamic `IsIsolatedFromAbove` trait support and exposes it
to Python as `IsIsolatedFromAboveTrait`.
The test verifies that a region with the trait cannot capture an SSA
value from above, while a region without the trait can.
Assisted by Codex/GPT 5.6 Sol (for writing test cases).
[libclang/python] Remove CompletionString.AvailabilityKindCompat (#210682)
This completes the fourth step of
https://github.com/llvm/llvm-project/pull/156680
This change is a follow-up to
https://github.com/llvm/llvm-project/pull/160296, following the release
branching, to ensure a one release-cycle deprecation period.
---------
Co-authored-by: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
[mlir][xegpu] Make convert_layout input_layout optional (#210833)
Make the `input_layout` attribute of `xegpu.convert_layout` optional.
When it is not set, the effective input layout defaults to
`target_layout`, i.e. the source is assumed to already be in the target
distribution.
assisted-by-Claude
Co-authored-by: Claude Opus 4.8 <noreply at anthropic.com>
[mlir] [vector] Allow element/broadcast re-order for FMA if the source is a vector (#211208)
The diagnostic says the transform is not performed as the source may be
a scalar. But we can make it if we can check the source is not a scalar.
AI assisted.
[lldb] Fix heap-use-after-free in FileSpec usage (#211908)
After #211394, `FileSpec` stores m_filename as a `SmallString` instead
of `ConstString`. When the `FileSpec` goes out of scope / is destructed,
a `StringRef` pointing to m_filename is now invalid. Previously it would
have worked even after `FileSpec` goes out of scope since `ConstString`
stores the string in a global buffer which is never destructed.
This causes heap-use-after-free in `CommandInterpreter` when we use the
result of `GetFilename()` on a temporary `FileSpec`. Store the result of
`HostInfo::GetProgramFileSpec()` as a variable to prevent it from going
out of scope before we're able to call `GetHomeInitFile()`.
Although #211394 introduces this failure, technically speaking this is
an existing bug, it was just masked because of how `FileSpec` used to
use `ConstString` to force a long lifetime.
[LoopInfo] Store blocks using Euler tour representation (#211485)
Block list construction appends each block to all enclosing loops
(O(depth) per block), and each loop owns a separately allocated vector.
Switch to an Euler tour representation: one BlockLayout array per
LoopInfo holding the in-loop blocks in a loop-contiguous reverse
postorder, each loop's list a [begin, end) slice of it, subloop slices
nested inside their parent's. Headers remain first;
`SubLoops`/`TopLevelLoops` orders are unchanged. A few tests observe the
order and are updated. (Previously a loop's list was the function's
reverse postorder restricted to its members, so a subloop's blocks were
interleaved with the parent's own blocks at their RPO positions.)
Mutations first copy a borrowed slice into private storage from
LoopInfo's allocator. `contains(BlockT *)` remains map-based: a
materialized loop's slice is not a membership test. This copy is rare:
across default<O2> over dagcombiner and sqlite3, only 12--14% of loops
built by analyze() are ever mutated; the rest keep the borrowed slice.
[4 lines not shown]
[flang][cuda] Accept statement function in device code (#211957)
Statement functions are inlined during lowering, so they should not be
treated as host procedure calls. Recursively validate their expressions
to reject any host procedure calls within the body.
[libc] Add symbolic constants for si_code values. (#211945)
Extend SIGCHLD-specific `si_code` values, already available in
`signal-macros.h` with Linux values for the rest of the signal-specific
codes specified in the POSIX.1-2024.
[OpenMP] Propagate PRESENT to pointee entries in mapper codegen
Extend map-type-modifier propagation in emitUserDefinedMapper to the PRESENT
modifier, but only for entries that have an attach ptr (the pointee data, whose
storage differs from the struct's own). A present modifier on the outer clause
must require that pointee to be present on the device.
This is gated on a new PropagatePresentToPointee argument, which Clang sets from
CGM.getLangOpts().OpenMP >= 60. Before 6.0 the present modifier is treated as
not applying to the pointee: the spec committee confirmed the divergence
between the present motion modifier (to/from) and the present map-type modifier
(map) was unintentional, to be fixed as an OpenMP 6.0 erratum. Only propagation
is gated; present written directly in a mapper's own clause applies at all
versions.
A TODO notes PRESENT should also propagate to the struct's own members, which
is blocked while pointer members use PTR_AND_OBJ.
Update the present-check tests to their final 6.0-gated behavior.
[2 lines not shown]
[OpenMP][Clang] Enable ATTACH-style maps for mappers.
Track per-entry attach-ptr info (HasAttachPtr) through mapper codegen so that
emitUserDefinedMapper does not add a new outer MEMBER_OF to pointee/combined
entries (which occupy different storage than the struct) or to ATTACH entries.
Clang and the MLIR translator populate the per-entry array in parallel with the
other MapInfosTy arrays.
Address review:
- Rename MapSkipMemberOfArrayTy to MapHasAttachPtrArrayTy to match the
HasAttachPtr field it backs.
- Restructure the emitUserDefinedMapper comment into a bulleted (*)/(**)/(***)
list keyed to the example entries.
- Reword the Clang comments: HasAttachPtr marks pointee entries that have a
base attach-ptr; a combined entry has a base attach-ptr if its constituents
do; cross-reference emitUserDefinedMapper for the MEMBER_OF rationale.
- Update the moved present-check tests to their now-correct behavior (the
attach-style maps make the inbounds present checks pass and remove the
"explicit extension" errors).
[2 lines not shown]
[OpenMP] Propagate ALWAYS/DELETE/CLOSE map-type modifiers to mapper entries
When a map clause uses a user-defined mapper, the map-type-modifying bits
(ALWAYS, DELETE, CLOSE) on the outer clause must apply to each map the mapper
inserts (OpenMP 6.0:281:34). Propagate them in emitUserDefinedMapper by OR-ing
the imported modifier bits into each pushed component, except ATTACH entries
(ATTACH|ALWAYS is reserved for attach(always) and the other bits are
meaningless for ATTACH).
PRESENT is intentionally not propagated here yet (a TODO notes it is handled in
a follow-on, since it requires distinguishing pointee entries from the struct's
own storage).
Update offload mapper_map_always_from.c to its now-correct behavior: ALWAYS
forces a member copy-back that the ref count would otherwise suppress, so s.y
reads back as 111 (it was 0 before this change).
Co-Authored-By: Claude Opus 4.8 <noreply at anthropic.com>
[OpenMP][test] Address review: restructure present-check mapper tests
Move the present-check pointee tests into this PR (PR1) with RUN lines and
FIXME/EXPECTED comments matching the current pre-feature behavior, per review:
- mapper_map_present_ptee.c
- mapper_map_mbr_ptee_then_present_mbr_ptee.c
- mapper_map_mbr_then_present_mbr_ptee.c
Later PRs update these checks as the behavior becomes correct. Also add
mapper_map_always_from.c showing the current (pre-propagation) ALWAYS behavior
(s.y = 0), which the ALWAYS/DELETE/CLOSE propagation PR flips to s.y = 111.
Also:
- mapper_map_ptee_then_present_absent_mbr.c: reword the FIXME to just say
PRESENT should be propagated to the s.x member entry (drop the PTR_AND_OBJ
wording, which belongs in the propagation PR).
- mapper_target_update_present_ptee.c: add OOB CHECK/EXPECTED lines and a
subset-transfer FIXME; use fprintf consistently.
- target_map_nested_ptr_member_mapper_codegen.cpp: add the OpenMP 6.0 RUN
line now (CHECK-60 currently identical to CHECK, with a FIXME) so the
[3 lines not shown]
[analyzer] Match dangling subobjects by their base region in DanglingPtrDeref (#211552)
Currently the `DanglingPtrDeref` checker only records the whole object's
region as deallocated. However, dangling pointers often refer to
subobjects (e.g., a struct field or an element of an array). With the
change in this PR, `isDeallocated` now checks whether a region's base
region is in the `DeallocatedSourceSet`.
[Clang] [Sema] Use getCurFunctionDecl() to get the current function (#211938)
In `BuildReturnStmt()`, use `getCurFunctionDecl()` to get the current
function rather than attempting to cast `CurContext` to a
`FunctionDecl`, which breaks inside an expansion statement because the
current `DeclContext` will be that of the expansion statement, not the
function. `getCurFunctionDecl()` knows how to handle this case and we
already call it earlier in that function, so just reuse the result of
that call.
Fixes #211917.
[libc][cpp::string] Do not count null terminator in capacity() (#211918)
Currently, `capacity()` includes the null terminator of the backing
buffer, which does not align with C++20's `std::string`. That is,
`s.reserve(s.capacity())` should be a no-op. While there's no
requirement these be in-sync, it is less surprising to align its
behavior.
Also, this fixes the case where `reserve()` is called on an empty
string, where previously the null terminator was not set.
clang/AMDGPU: Migrate cc1 tests to subarch triples (8)
Rewrite SemaHIP cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (9)
Rewrite SemaOpenCL cc1 test RUN lines to the new subarch triple form,
dropping the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (11)
Rewrite the second half of CodeGenOpenCL cc1 test RUN lines to the new
subarch triple form, dropping the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>
clang/AMDGPU: Migrate cc1 tests to subarch triples (10)
Rewrite the first half of CodeGenOpenCL cc1 test RUN lines to the new
subarch triple form, dropping the redundant -target-cpu.
Co-authored-by: Claude (Opus 4.8) <noreply at anthropic.com>