[flang][cuda] Allocate descriptors in managed memory only when the device reads them (#234579)
Example:
```fortran
subroutine s(x)
real, device :: x(:)
end subroutine
real, device, allocatable :: a(:)
allocate(a(8))
do i = 1, n
call s(a)
end do
```
In this code, each `call s(a)` builds a temporary descriptor for `a`.
Codegen stores a temporary descriptor either in an `alloca` or, when
`isDeviceAllocation` says the data is device-resident, in managed memory
from `CUFAllocDescriptor`. A managed descriptor may be read by an
[16 lines not shown]
[Flang][OpenMP] Fix OpenMP data-mapping stride calculation (#225653)
The calculation of strides when mapping individual sub-arrays from
multi-dimensional array, the calcuation of the stride was missing such
that when mapping all of the multi-dim array only a fraction was
actually mapped.
---------
Signed-off-by: Dominik Adamski <dominik.adamski at amd.com>
Co-authored-by: Dominik Adamski <dominik.adamski at amd.com>
Co-authored-by: Claude Opus 4 (1M context) <noreply at anthropic.com>
[ThinLTO] Write distributed index summaries in GUID order (#234322)
The writer emitted each module's summaries in DenseMap order, which
depends on insertion order. Adding or changing an unrelated module can
change that order, so an unchanged module's .thinlto.bc gets different
bytes even though its contents are the same. Build systems that cache
backend compiles by input bytes then rerun them for nothing.
Sort the summaries by GUID before writing, as the full-index path
already does.
Assisted by Opus 5.5
rwhich: resolve the directory index only once
The file listing of a repository starts with a dictionary of all the
directories it references, which can hold close to a million entries for
the ports repository.
Empty lines delimit both the dictionary from the packages and the packages
from each other, so the code looking up the requested directory in the
dictionary was run again for every package. When the directory is not
found, whole dictionary was scanned once per package.
Look the directory up only once, when the dictionary has been parsed.
[libc][math] Optimize exp and share double-precision evaluation with exp2.
Refactor double-precision exp to share most of the computations with exp2,
and adding support for `LIBC_MATH_HAS_SMALL_TABLES` and
`LIBC_MATH_HAS_SKIP_ACCURATE_PASS`.
Assisted by: Gemini is used for performance and code size analysis and refactoring.
[ORC] Remove declarations without definitions (NFC) (#234496)
The definitions of JITDylib::transferEmittedNodeDependencies and
JITDylib::addDependencies were removed on January 31, 2024 in commit
ebe8733a11e735bb9f5ca45ec752c2a416380c8d, leaving the declarations
behind.
Assisted-by: Antigravity
[clang][ClangScanDeps] Match pcm file names in logging-two-threads.c (#234319)
The test's patterns for A's and B's pcms were too coarse: they match any
line whose path contains `A-` or `B-`, not just the pcm files. Some CI
environments have such paths, and there the TSA count (added in
0db95253f939, #210587) also counts B's line, and fails when both threads
validate A.
This PR matches the modules by their pcm file names (e.g.
"/A-<hash>.pcm").
rdar://190466150
Assisted-by: Claude Opus 5.5
[flang][CUDA] Clarify host and device call diagnostics (#232850)
Report the callee's CUDA attribute and the calling context in CUDA
procedure-call diagnostics. Retain both the referenced generic name and
the selected specific procedure name when they differ, and report actual
attributes such as GRID_GLOBAL instead of inferring the callee kind from
the caller.
For example, a call to a HOST procedure from an unguarded HOST,DEVICE
procedure reports:
```text
'foo', a procedure with the HOST attribute, may not be called from HOST,DEVICE code
```
Use lowercase `host` and `device` for individual calling contexts and
uppercase `HOST,DEVICE` for the combined context. Keep attribute names
uppercase. The message does not prescribe an ON_DEVICE() guard, since
some rejected calls occur in specification expressions where an IF guard
[7 lines not shown]
[CIR] Support CoawaitExpr in emitLValue (#232280)
In `CIRGenFunction::emitLValue`, `Expr::CoawaitExprClass` previously
called `errorNYI`. When a coroutine awaits an expression whose
`await_resume()` returns an lvalue reference (for example, `int &x =
co_await awaiter;` or `(co_await awaiter) = 42;`), Clang evaluates the
`CoawaitExpr` as an lvalue.
This patch:
- Routes `Expr::CoawaitExprClass` to `emitCoawaitLValue` in
`CIRGenFunction::emitLValue`.
- Refactors `emitCoawaitLValue` and `emitCoyieldLValue` into a shared
`emitSuspendLValue` helper.
- Handles resume expressions in try/catch (where `tmpResumeLValAddr` is
null) by asserting `isResumeExprInTryCatch` and returning a null pointer
lvalue.
- Adds FileCheck tests in
`clang/test/CIR/CodeGenCoroutines/coro-await.cpp`, including test
coverage with C++ exceptions enabled.
Fixes #232232.
fixup! [AArch64][llvm] Combine SVE AND-NOT operations into BIC for _m forms
Select merging AND-NOT operations with TableGen patterns instead of the C++ combine. Preserve the first operand in inactive lanes and use an unpredicated BIC when both predicates are all-active.
[AArch64][llvm] Combine SVE AND-NOT operations into BIC for _m forms
Replace NOT followed by merging AND with BIC for expressions such as:
return svand_u32_m(pg, a, svnot_u32_x(pg, b));
Combine when NOT is the second operand and its predicate matches the AND
predicate or is all-active.
Use predicated BIC to preserve the AND's first operand in inactive
lanes. Use unpredicated BIC when the AND predicate is all-active.
Do not commute merging AND operands, since this would change inactive
results. Leave pairs with incompatible predicates unchanged.
This applies to all integer element widths. Update the pre-commit LLVM
expectations, including cases where combining would change the
result.
[libc] Deduplicate va_list to argv extraction using exec_with_arg_list (#234581)
Deduplicate the `va_list` to `argv` VLA extraction logic across `execl`,
`execle`, and `execlp` into a shared `internal::exec_with_arg_list`
helper in `libc/src/unistd/linux/exec_utils.h`.
Follow-up to #232901 suggested by @labath.
fixup! [AArch64][llvm] Combine SVE AND-NOT operations into BIC for _x forms
Remove the extra AND_U patterns for all-active NOT, ordinary LLVM NOT
and register AND fallback. The C++ helper lowers ordinary cases to
AND and retains matching-predicate AND-NOT pairs for the remaining BIC
pattern.
[SPIRV] Emit each debug scope from getOrCreateDebugScope.
Handlers return the opcode and the operands. getOrCreateDebugScope writes that instruction with a fresh id.
[libc][cmake] Unify test suite creation and hierarchy in add_libc_testsuite. (#234465)
- Expand `add_libc_testsuite` to unconditionally create `<suite_name>`
and `<suite_name>-build` and wire them into `<parent_suite>` and
`<parent_suite>-build` (defaulting to `libc-tests` unless `ROOT` or
`PARENT <parent_suite>` is specified).
- Remove lazy test suite creation.
- Folding `add_libc_exhaustive_testsuite`,
`add_libc_long_running_testsuite`, and `add_libc_integration_test_suite`
into `add_libc_testsuite`.
- Consolidate `NO_RUN_POSTBUILD` and exhaustive suites into a single
`BUILD_ONLY` option across `add_libc_testsuite` and `add_libc_test`,
naming executables `*.__build_only__` so Lit ignores them during
`check-libc` while keeping `<fq_target_name>` runner targets for manual
invocation.
- Migrate all test suite definitions across `libc/test/` and
`libc/benchmarks/gpu/` to `add_libc_testsuite` and standardize suite
names on `libc-*-tests` and `libc-*-integration-tests`.
Assisted-by: Gemini
[libc] Use a syscall wrapper for `epoll_ctl` (#234572)
This PR move `epoll_ctl` behind the centralized syscall wrappers,
following `libc/docs/dev/syscall_wrapper_refactor.md`.
[MemProf] Honor trimmed contexts when assigning callsite clones to function clones (#230351)
Contexts trimmed at a callsite's frame are on that node's callee edges
but not its caller edges, so when the node (or one below it on their
path) is cloned for another allocation's contexts, the clone gets no
edge to the callee nodes the trimmed contexts flow through. Function
assignment then placed such clones without regard to them, possibly in a
function clone calling the wrong version of the callee for the trimmed
contexts, which are caller-agnostic and apply to the clone equally (see
trimmed-context-clone.ll: top1's path loses the cold hint for leafA).
Handle this in assignFunctions (new method assignImplicitCallers):
trimmed ids are collected up front, and after a callsite's clones are
assigned, clones of a caller that have no edge to the callsite's clones
but that the trimmed contexts on the caller's edge would have reached
(checked up the caller chain) are implicit callers requiring the same
callee version. If unassigned, they get the caller's function clone; if
in a function clone without a clone of the callsite, that call follows
the caller's (the required clone is recorded with one of its trimmed ids
[13 lines not shown]