[SPIRV] Implement bare bones lowering for G_PREFETCH (#215505)
Map G_PREFETCH to OpenCL prefetch if SPV_KHR_untyped_pointers is not
enabled, otherwise drop.
Fixes https://github.com/llvm/llvm-project/issues/214265
[Flang][OpenMP] PoC module support for allocate directives
This patch implements partial support for `allocate` on Fortran
module variables, based on adding global constructor functions for each
impacted variable.
Shared as a proof of concept, because I have a few concerns about it:
1. It appears that Clang ignores `allocate` directives on global
variables instead. Is that the expected behavior?
2. The existing implementation for `allocate` in Flang doesn't
actually impact where the memory used for a variable resides. It
allocates/deallocates extra memory for it using OpenMP internal
compiler calls but then that storage is never used. The original
alloca is still used. This addition suffers from the same issue:
global constructors allocate extra memory that is never used to
update in any way the associated global variable or its users.
3. No `omp.allocate_free` (should be `omp.allocate.free`) can be added
by this approach.
4. The representation of `omp.allocate_dir` (should be `omp.allocate`)
[10 lines not shown]
[lldb-dap][NFC] Fix deprecated SB API usages (#216006)
lldb-dap has accumulated over time several calls to deprecated SB API
functions. Since #215818 we actually emit the missing deprecation
warnings which breaks the lldb-dap build with -Werror. This patch
replaces the deprecated functions with the equivalent non-deprecated
version.
Note that this patch is intentionally NFC and I just added TODOs for the
missing error handling.
assisted-by: claude
[APINotes] Strip selector volatile and nested nullability from parameter selectors (#215266)
Address @Xazax-hun's comments about volatile and nullability stripping
from
https://github.com/llvm/llvm-project/pull/213043#pullrequestreview-4830763715.
This strips top-level `volatile` like top-level `const` when building
`Where.Parameters` selector spellings, and recursively strips
nullability through pointer-like layers such as `int * _Nullable *
_Nullable`.
This is a prequel PR to
https://github.com/llvm/llvm-project/pull/213043.
Reviewers: @Xazax-hun @j-hui @egorzhdan
[RISCV] Fix prefetch ADDI-adjustment range upper bound (#215985)
SelectAddrRegImmLsb00000 folds a large constant offset into an ADDI plus
a simm12_lsb00000 prefetch immediate. The positive range [2017, 4065]
overflowed simm12 at the top end: CVal - 2016 reaches 2048/2049,
producing an invalid ADDI. Narrow it to 4063; 4064/4065 now fall through
to selectConstantAddr instead.
Revert "[offload] Fix compatibility for level_zero 25.22.33944- #2142… (#216010)
…15 (#215977)"
This reverts commit 77c8ecd7a6b912b6c61665f623f864c4cba52a00.
Level zero approach to zex pointers is a little inconsistent and I need
to rework the PR. Some APIs such as
`zeCommandListAppendLaunchKernelWithArguments` would return `SUCCESS` on
older versions and provide a valid pointer to implemntation, but in more
recent versions of level zero you would get `ERR_INVALID_ARGUMENT`.
[libc++][pstl] Implementation of parallel uninitialized_default_construct, uninitialized_value_construct and uninitialized_fill (#214580)
This PR adds parallel versions of these functions:
- `std::uninitialized_default_construct`
- `std::uninitialized_default_construct_n`
- `std::uninitialized_value_construct`
- `std::uninitialized_value_construct_n`
- `std::uninitialized_fill`
- `std::uninitialized_fill_n`
They use parallel `for_each` under the hood and are effectively
one-liners, e.g.:
```c++
return ForEach()(policy, std::move(first), std::move(last), [&value](Ref element) {
::new (static_cast<void*>(std::addressof(element))) ValueType(value);
});
```
Fixes #134590.
[4 lines not shown]
[Flang][OpenMP] Prevent allocate directive ICE on module variables
The current lowering implementation for `allocate` directives assumes
the MLIR function in which it is creating operations will still be there
by finalization time, so that it can add a deallocation call.
When lowering Fortran modules, this is not the case (lowering happens
in a temporary dummy function) and it results in a compiler crash
while running cleanup callbacks. This patch adds a TODO for this case.
clang/AMDGPU: Respect __launch_bounds__ attribute (#215615)
Currently the HIP headers manually implement this with a
macro setting amdgpu attributes, and the proper clang attribute
is silently ignored. Directly map the proper attribute into
the target IR attributes. The first argument sets
"amdgpu-flat-work-group-size" and the second (reinterpreted by HIP
as minimum waves per EU) sets "amdgpu-waves-per-eu". An explicit
amdgpu_flat_work_group_size / amdgpu_waves_per_eu attribute takes
precedence. This matches the launch_bounds macro in the HIP headers,
which can now be dropped.
The 3rd maxclusterrank argument is only handled for NVPTX, so restrict
the sm_90 arch check to NVPTX targets and ignore the third argument on
other targets.
Fixes #91468
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[dyndbg][LLVM] Implement dynamic debugging support (#194854)
This patch adds support to LLVM to prepare a module for dynamic debugging.
`prepareForDynamicDebugging` modifies the input module (intended to be the
"optimized" module) and returns a modified clone (intended to be the
"unoptimized" module).
The (to be) optimized module holds global data referred to by both modules, and
all calls in the (to be) unoptimized module are to the optimized module
functions. To facilitate this the optimized module is modified, adding
external-linkage aliases for local symbols.
For more detail see RFC https://discourse.llvm.org/t/90113 and documentation at
llvm/docs/DynamicDebugging.md.
In later patches Clang will use this utility to implement ahead of time dynamic
debugging (compiling both optimized and unoptimized modules fully), though
additional modes may be supported in the future.
[libc++][ranges] Fix the LWG 3568 test for `basic_istream_view` (#215589)
The previous test was dereferencing `begin()` iterator on empty view
which is UB, because `begin() == end()`.
A new test case was suggested in a post-merge feedback in #193891, which
verifies LWG3568 through constant evaluation. Such a `constexpr`
`basic_istream_view` variable can only be created if it is completely
initialized, including its exposition-only _`value_`_ member.
The existing test case is changed to use a non-empty stream and a
testing class type for which `operator>>` is no-op. The state of the
class object stored in `basic_istream_view` is unchanged even after the
initial `operator>>` call.
This avoids dereferencing a past-the-end iterator while testing LWG3568.
[libc++] Trigger the benchmark-request job more often (#216003)
With the test suite taking under 1h to complete, it makes sense to
trigger at least every 30 minutes so we don't leave available capacity
unused.
[libc++][pstl] Implementation of parallel std::search_n() based on __parallel_find() (#214069)
This PR implements a parallel version of `std::search_n()` based on
`__parallel_find()`.
The algorithm crops the input range to a range where a potential match
can start and runs a chunked parallel find on the cropped range.
Inside each chunk potential matches are looked for and the first one
found is returned.
Since it's based on `__parallel_find()`, the algorithm supports early
termination.
[AMDGPU] Fix si-pre-emit-peephole to preserve S_AND when SCC is alive (#215829)
The optimization in si-pre-emit-peephole that removes S_AND_B64 after
V_CMP instructions does not check if the implicit SCC def is alive. This
causes miscompiles when the SCC value is used by subsequent
instructions.
Fixes #215745
[libcxx][FreeBSD] Mark unsupported only in XOPEN=500
FreeBSD hides all C99 definition when -D_XOPEN_SOURCE=500. As a result,
we can turn on these tests if we have definition higher than 500.
CodeGen: Remove TargetOptions::FloatABIType
This is now fully replaced with the "float-abi" module flag.
If the module flag is not present, the default is computed
from the triple. Consumers are updated to read the module flag.
RuntimeLibraryAnalysis now defers analysis until run() on a Module,
instead of during the pass constructor as before. This requires copying
all of the remaining relevant TargetOptions so they are available
when the module is seen.
Unfortunately, ARM still depends on TargetOptions for determining
the float-abi. -target-abi=aapcs16 still changes the default float-abi,
but an explicit module flag wins.
Co-authored-by: Claude (Claude-Opus-4.8) <noreply at anthropic.com>
[CodeGen] Take the executable stack from a module flag (#215152)
AsmPrinter marked `.note.GNU-stack` executable whenever the module had a
use of `llvm.init.trampoline`. This was not compliant with the
documentation for the function, which causes regressions in Julia.
Instead read a new `"executable-stack"` module flag, so that the request
comes from the frontend that emitted the code rather than from scanning
for an intrinsic and auto-magically (and wrongly) guessing. Update the
documentation to be even more clear about this implementation's
expectations (which matches gcc's abilities for the same).
Frontends generating code that needs an executable stack now have to set
the flag for that purpose. For example, flang will do so from
BoxedProcedurePass when it emits a stack based trampoline; the
`-fsafe-trampoline` runtime pool does not need one (nor was the custom
runtime intrinsics really necessary for `-fsafe-trampoline`, since the
existing intrinsic was already defined to support that use case too).
Fixes a regression caused by #151754, which introduced new behavior onto
[4 lines not shown]
[lldb] Fix crash when adding a python ParsedCommand (#215807)
The expected result of `ParsedCommand.get_args_definition` is a List of
Lists and should not crash when it is not the case.
[offload] Fix compatibility for level_zero 25.22.33944- #214215 (#215977)
This PR reapplies https://github.com/llvm/llvm-project/pull/214215. I
incorrectly checked `if (Result->Code == OL_ERRC_UNSUPPORTED)` without
checking if `Results != nullptr`. I didn't realize it failed when I ran
it locally, the segmentation fault was silent for some reason.