[OpenACC] Fix iterator-type lookup when kind is incomplete (#240424)
OpenACC loop needs to have a random access iterator, and does some
heroics to look into the 'iterator_category' to check for this. It ALSO
checks whether the type referred to in the iterator_category inherits
from std::random_access_iterator.
However, it was failing to make sure it was a definition before checked
for base classes, leading to an assert.
This patch adds that check, which will make a iterator category
incomplete type not attempt to check the 'base' class.
Fixes: #239962
[clang] Call getOrCreateFile() just once in AddStringLiteralDebugInfo() (#240382)
getOrCreateFile(Loc) is stored in a variable `File` 3 lines up,
so use that variable instead of calling the function again.
Mostly for code cleanliness, but for usb_ids_gen.cc (from #229808)
this is also a small (0.4%) reduction in retired instructions.
No behavior change.
[libcxx] Switch to llvm-premerge-linux-4-runners for benchmarking (#239065)
These are smaller so take up less resources when we only run benchmarks
on a single thread and they are also c2d vs n2/n2d which means that we
get exclusive cores rather than GCP overcommit.
Fixes #236840
[libc] Reland "Implement copy_file_range in unistd" (#240018)
This patch relands #236914 (reverted in #238956 / commit 53d0afa56861).
### Root Cause & Fix
The revert was caused by pre-commit CI failures where
`copy_file_range_test` encountered environments lacking
`copy_file_range` syscall emulation or running on container overlay
filesystems:
- Emulators return `EFAULT` or `ENOSYS` instead of `EBADF` on invalid
descriptors with `nullptr`.
- Container overlayfs / older kernels may return `EXDEV`, `ENOSYS`, or
`EOPNOTSUPP`.
### Changes in Reland
- Update `InvalidArgs` in `copy_file_range_test.cpp` to accept
`any_of(EBADF, EFAULT, ENOSYS)`.
- Gracefully handle `ENOSYS`, `EXDEV`, and `EOPNOTSUPP` in test copy
cases.
[4 lines not shown]
[LTO][NFC] Use runCodeGenPipeline
This abstracts across the LegacyPM and the NewPM. We add a new optional
parameter to runCodeGenPipeline to take in a ModuleSummaryIndex to
properly handle pipeline setup.
Reviewers: aengelke, teresajohnson
Pull Request: https://github.com/llvm/llvm-project/pull/240252
[NFC][ThinLTO] Use runCodeGenPipeline abstraction (#240226)
This makes the code slightly simpler by moving to a canonical
abstraction and also abstracts between the LegacyPM/NewPM without
additional handling specific to ThinLTO.
[lldb] Interrupt the read thread when stopping it
ThreadedCommunication::StopReadThread clears m_read_thread_enabled and
joins the read thread, which checks that flag only once its read
returns. When no data comes, the read returns only when it times out,
after five seconds.
Before lldb reports that a process it launched has exited or that it
detached from the process, it stops the read thread of the process's
terminal. A process that lldb detaches from usually keeps running, and
if it does not write to its terminal, the detach takes five seconds.
StopSTDIOMonitoring closes lldb's own descriptor for the secondary side
of the terminal first, but that ends the read only once the process has
closed its descriptors too. Meanwhile, debugserver or lldb-server exits,
and since the process is not detached yet, ProcessGDBRemote gives it an
exit status, so lldb reports that the process exited.
Interrupt the read after clearing the flag, as SynchronizeWithReadThread
does. A connection reports an interrupt only when no data is pending,
[3 lines not shown]
[CIR][SYCL] Fix null value emission in local addrspace for AMD and NVPTX targets (#237387)
Fixes null value emission bug in local address space for AMDGPU and
NVPTX targets. This is needed to port the following 2 tests from clang
CodeGenSYCL to CIR CodeGenSYCL:
- amd-address-space-conversions.cpp
- cuda-address-space-conversions.cpp
[SCEV] Drop redundant umax when applying signed lower-bound guards. (#237779)
When applying a guard From s>= RHS with a non-negative constant RHS,
From u>= RHS holds as well. If From has already been rewritten to
umax(C, From) with C u<= RHS, the umax is redundant and can be dropped.
This avoids losing range information, as the range of umax(C, From) may
be much less precise than the range of From when using SMax.
More precise range enables additional unrolling end-to-end
https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1923.
PR: https://github.com/llvm/llvm-project/pull/237779
[lldb][test] Build PDB test inferiors with column info (#238604)
Clang emits columns into DWARF line tables by default but leaves them
out of `CodeView` unless `-gcolumn-info` is passed, so pdb test
inferiors have no columns.
This patch passes `-gcolumn-info` for `MAKE_PDB` builds.
Fixes `TestBreakOnCPP11Initializers`, `TestStepThroughTrampoline` and
`TestStructuredBinding` with PDB debug info.
rdar://191741281
[SelectionDAG] Add selectShiftAmountMask and use it for RISC-V (NFC) (#240214)
Many targets drop a shift-amount AND that keeps every bit the shift
reads, each with its own code. This moves RISC-V's version into
`SelectionDAGISel::selectShiftAmountMask` so other targets can share it.
X86 uses it next, for #199697.
The helper looks through one truncate and an AND whose constant, with
known-zero bits, keeps the low Log2(width) bits. It sets the output only
on success. It ignores other users of the AND, so each target decides
that.
RKSimon suggested a TableGen-level fix in #199697. This shares the C++
selector behind target ComplexPatterns instead.
RISC-V output does not change.
Assisted-by: Claude Opus 5.5
[IRBuilder] Add support for GEP canonicalization (#237255)
This implements support for GEP to ptradd canonicalization in IRBuilder:
Arbitrary GEPs will be converted into a sequence of ptradd
(getelementptr i8) or scaled ptradd (getelementptr [N x i8]).
Because this has substantial impact on existing tests, this is currently
off by default, with only InstCombine opting in via
enableGEPCanonicalization(). InstCombine already canonicalizes itself,
so this only changes a few edge-cases.
The plan is to then opt-in a few more places, then convert the opt-in to
an opt-out, and then remove the opt-out.
[mlir][NFC] Remove includes of headers declaring used traits and interfaces (#240404)
The generated declarations of ops, attributes, types and interfaces now
include the headers declaring the core traits and interfaces they use.
Includes that headers only had for these generated declarations are
therefore redundant. This removes them in MLIR, Flang and ClangIR.
Includes of headers that the hand-written code uses directly are kept,
even when the generated code includes them as well.
Co-authored-by: Claude <noreply at anthropic.com>
[OpenMP] Use device scope for atomic constructs on the device
OpenMP 6.0, 17.8.5 specifies that "The memscope clause determines the
binding thread set for an atomic region. If the memscope clause is not
present, the behavior is as if the memscope clause appeared on the
construct with the device scope-specifier."
Thread the sync scopes through codegen amd also add a release note
because this is changing existing behavior.
Existing behavior was overly cautios for OpenMP 5.2, too, though. The
atomic construct never specified the option of having system-level
scope. This only came with the memscope clause and it's "all"
scope-specifier.
Claude assisted with this patch.
[MLIR][XeGPU] Limit transposed 2D block load height to 16 (#239469)
The hardware supports transposed 2D block loads with height 16 or 32,
but a 32-row tile does not align with the DPAS layout. Limit the
8/16/32-bit transposed block load entries in the uArch table to height
16.
Layout propagation now falls back to inst_data [16, 8] for a transposed
i32 load whose consumer asks for 32 rows, and the peephole optimizer
splits 32-row transposed loads into two 16-row loads.
Add a propagate-layout-inst-data test covering the fallback, and update
the peephole-optimize CHECK lines for the split loads.
assisted-by-claude
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[OpenMP][clang] Apply atomic options to atomic compare
Thread denormal mode, fine-grained memory and remote memory options
through for atomic compare directivs.
Claude assisted with this patch.
[AMDGPU] Remove V_CNDMASK_B64_PSEUDO handling from SIFoldOperands. NFC. (#240324)
This is dead because the pseudo always gets expanded earlier, and broken
because it would have used V_MOV_B32 to move a 64-bit value.
[libc] Apply scheduler attributes on thread creation (#225674)
POSIX specifies that pthread_create should apply the scheduling policy
and parameters given in the attributes object (if PTHREAD_EXPLICIT_SCHED
is set). Linux's clone syscall doesn't support setting scheduling
parameters directly, so we have to apply them from userspace via
sched_setscheduler after the thread is created.
To make sure the thread doesn't start running user code with the wrong
scheduling parameters (and to allow returning an error if
sched_setscheduler fails without leaving a half-running thread), I've
added a startup handshake using the clear_tid futex on the child stack:
- the child waits on the futex if explicit scheduling was requested
- the parent calls setschedparam, and then signals the child to either
continue (running) or abort (exit)
- if the call fails, the child exits immediately, the parent reaps it
via Thread::wait(), and returns the error code to the caller
Assisted-by: Gemini
[OpenMP][clang] Add ompx_fast_fp_atomics and ompx_safe_fp_atomics hints
Add omp_sync_hint_t extensions that override
-f[no-]atomic-ignore-denormal-mode (-m[no-]unsafe-fp-atomics) for a single
atomic construct. The safe hint takes precedence if both are given.
This is an upstreaming/copy-paste of downstream code and release notes.
Claude assisted with this patch.