[clang] Disambiguate lambdas from Microsoft attributes (#214247)
With -fms-extensions, a CUDA/HIP lambda capture list can be consumed as
a Microsoft attribute list. This causes attributed lambdas used in
direct initialization to be misparsed as function declarators.
Tentatively inspect the tokens following the capture list and any
trailing attributes to identify lambdas before parsing Microsoft
attributes.
Assisted by: Cursor / Claude Opus 4.8
[libc] Implement clone(2) and use it in thread spawning (#224257)
This patch implements an internal clone syscall wrapper and uses it both
to implement the public clone(2) entry point and to spawn new threads in
libc's thread implementation.
Previously, thread creation in thread.cpp invoked the raw SYS_clone
syscall directly, requiring target-specific inline assembly or register
variables and subtle tricks with __builtin_frame_address to pass
arguments to start_thread in the newly spawned thread.
By introducing an inline assembly clone wrapper that sets up func and
arg on the child stack and jumps to the entry function upon clone
returning in the child, we can simplify start_thread to a normal
function taking a single void * argument and eliminate the frame pointer
hacks as well as the need to compile thread.cpp with
-fno-omit-frame-pointer or optimizations.
The public clone(2) entrypoint delegates to this wrapper after unpacking
[16 lines not shown]
[SystemZ][z/OS] Extend systemz-features.cpp and zvector.c with z/OS RUN lines (#224733)
Add `s390x-ibm-zos` RUN lines to
`clang/test/Driver/systemz-features.cpp`
covering the default, `-mhtm`/`-mno-htm`, and `-mvx`/`-mno-vx` cases.
The `-mvx` z/OS lines require `-march=arch11` because the default z/OS
CPU (zEC12) pre-dates vector support.
Add a second RUN in `clang/test/Sema/zvector.c` using triple
`s390x-ibm-zos` with `-target-cpu z13` so the file is exercised under
the z/OS code path.
These test extensions were carved out from
https://github.com/llvm/llvm-project/pull/223026 per reviewer request
(@uweigand): the extra test runs are good additions but are not related
to the i128 XPLINK64 change.
[flang][OpenMP] ORDERED clause is allowed on DO in 4.5+
Several compound directives containing DO were missing the ORDERED
clause in the set of allowed (once) clauses.
[orc-rt] Implement Windows CPU feature detection (#224516)
Adds Windows CPU feature detection for ORC-RT.
Currently supports x86-64 using the Windows/MSVC CPU feature interfaces.
Additional architectures can be added as needed.
[Flang][FIR] Handle SequenceTypes in isRecordWithAllocatableMember (#224048)
Currently isRecordWithAllocatableMember does not handle sequence types,
either at the top level on the input type or in subsequent nestings, it
will effectively skip them. This is quite different to how
isRecordWithDescriptorMember handles these cases, as it does in fact
unwrap sequence types to correctly dictate if there are descriptor
members inside of a record type.
This PR simply aims to align the behaviour with
isRecordWithDescriptorMember, as there are several locations where
isRecordWithAllocatableMember is being used and the expectation is that
it will indicate if there's an allocatable member inside of the record
type irrespective of sequence types being part of the equation.
[AMDGPU] Do not fold clamp when only one max source has modifiers (#224517)
Fix isClamp to bail if either max source has a modifier, not only when
both do. Previously `max(x, |x|)` was wrongly folded as if it were x
[clang][Driver] Use --no-rosegment for LoongArch Linux
Pass --no-rosegment when linking LoongArch Linux targets so that read-only
code remains in the first LOAD segment, matching the GNU ld layout.
This allows Linux to make more effective use of file-backed PMD mappings and
reduces iTLB misses.
[AMDGPU][MC] Upstream gfx11/gfx12 true16 assembler test coverage
Upstream new assembler test cases, covering true16 .l/.h operands and op_sel
handling that had no upstream coverage.
[AMDGPU][MC] Upstream gfx12 true16 disassembler test coverage
Upstream new gfx12 disassembler test cases, covering true16 operand (.l/.h)
and op_sel decoding for f16 opcodes that had no upstream coverage:
[AMDGPU][MC] Upstream gfx11 true16 disassembler test coverage (#223823)
Upstream new gfx11 disassembler test cases, mostly covering true16
operand
(.l/.h) and op_sel decoding that had no upstream coverage.
[offload][omp] Move OpenMP KLE to libomptarget
Move preparations related to OpenMP KLE and
dynamicCGroupMem fallback out of the plugins and
into libomptarget.
Resructure Device::launch as it grew too large.
[ORC] Mangle SimpleNativeMemoryMap CI names as C (#225074)
Flip the SimpleNativeMemoryMap memory-manager descriptors (instance +
reserve/initialize/deinitialize/release) from Verbatim to C, so their
names carry the target's C mangling. The controller and in-tree executor
mangle the same specs, and no other provider defines these names, so
they stay in sync; nothing else defines these names.
Also update the CreateFromExecutionSession test to use the process
triple so that its name mangling matches the target mangling above.
[AMDGPU][InstCombine] Fold zero dot operands to accumulator
Fold AMDGPU dot intrinsics when either operand is zero.
`dot(a, 0) = 0` and `dot(0, b) = 0`, so replace the intrinsic with its accumulator.
This avoids unrelated clamp and add/sub reassociation cases.
[AMDGPU][InstCombine] Canonicalize dot constant operands
Move constant dot product source operands to the right hand side
and add tests for signed and unsigned dot intrinsics.
[AMDGPU][InstCombine] Fold constant add/sub into the dot accumulator
`amdgcn.{s,u}dot{2,4,8}(a, b, C) +/- K -> dot(a, b, C +/- K)` when both the
accumulator C and K are constants. The new constant is computed with
wrapping APInt arithmetic to match the non-clamping accumulate.
Only applies when clamp is false (the saturating accumulate does not
reassociate) and the dot has a single use. K - dot is left alone since it
would need the dot product negated.
LTO: Stop overwriting the merged module's DataLayout (#223987)
LTOCodeGenerator::optimize() unconditionally reset the merged module's
DataLayout from TargetMachine::createDataLayout(). The merged module
already carries the correct DataLayout since IRMover propagates the source
module's layout into the empty destination. The module should be the source of
truth for its DataLayout.
Recomputing it from the TargetMachine is also latently wrong, since the
DataLayout depends on the target-abi module flag which the
TargetMachine's cached DataLayout cannot account for.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[clang][OpenMP] ORDERED clause is allowed on FOR in 4.5+
Several compound directives containing FOR were missing the ORDERED
clause in the set of allowed (once) clauses.
[offload][omp] Move OpenMP KLE to libomptarget
Move preparations related to OpenMP KLE and
dynamicCGroupMem fallback out of the plugins and
into libomptarget.
Resructure Device::launch as it grew too large.