[mlir][acc] Translate the acc.offload_entry attribute to an offloading entry
Add the acc.offload_entry unit attribute, which marks a global host symbol
(either a function or a global variable) that the offload runtime must be able
to associate with its device counterpart. The translation emits entries that
are registered with the OpenACC runtime libacctarget.
Assisted-by: Claude Sonnet 5.5
[mlir][acc] Translate #acc.offload_packager to LLVM IR
Add a translation library for the OpenACC dialect that implements the
offloading translation interface of #acc.offload_packager. Each object
of a gpu.binary is wrapped in an offloading binary of kind OpenACC,
carrying the target triple and architecture, and the images are placed
in the .llvm.offloading section of the host module for the offloading
linker wrapper to extract.
Assisted-by: Claude Sonnet 5.5
[mlir][acc] Add the #acc.offload_packager offloading handler (#242807)
Add an offloading handler attribute for gpu.module and gpu.binary that
is meant to embed the device images in the host object as LLVM
offloading binaries of kind OpenACC, for the offloading linker wrapper
to link and register with the OpenACC runtime.
Assisted-by: Claude Sonnet 5.5
[ARM64EC] Fix vararg pointer in entry/exit thunks for 16-byte return value (#237817)
When a function returns a 16-byte structure, in the x86-64 calling
convention it is returned in memory with a hidden pointer, but in the
ARM64EC calling convention it is returned in {X0,X1} so it does not have
a hidden pointer. In this case the x86-64 function has one more
argument, and up to at most three arguments can be passed in register --
X4 now points to the 4th argument, instead of the 5th as the old code
mentioned.
In the exit thunk, the reverse applies: The ARM64EC function does not
pass a hidden pointer, but the x86-64 function expects one, causing the
4th argument (if any) to spill on the stack.
This commit shifts arguments by one, pops one argument from the stack
into an integer register, and adds X4 by 8 so it will point to the 5th
argument as ARM64EC expects.
Assisted-by: DeepSeek V4.1 Flash
[Hexagon] Reserve V30 for v79 QFloat handling (#243763)
For v79, floating point vector operations involving extended qfloat, we
need to use v30 as a scratch register in the post RA Xtended QF handling
pass. We reserve it when we use xqf for v79 for non-legacy mode, ie.
strict-ieee, ieee or lossy mode when xqf instructions are present.
Fixes #237215
Co-authored-by: quic-santdas <quic_santdas at qti.qualcomm.com>
[Driver] Support -rtlib=none (#245001)
This is helpful in situations when linking the runtime library is
undesirable, for example when building the runtime library itself. It
also makes the --rtlib= option consistent with --unwindlib=.
[IPO] Declare sample profile inliner command line options in TableGen (#244670)
SampleProfile.h replaces the exported cl::opts with
SampleProfileInlineOptions, which
SampleProfileLoaderPass::getInlineOptions fills from the options given
over the caller's defaults. llvm-profgen's preinliner reads its
thresholds this way instead of writing the cl::opts, and the loader no
longer writes the global size limits for non-CS profiles.
[orc-rt] Define _GNU_SOURCE in the dlfcn-host regression test. (#245124)
glibc's <dlfcn.h> only declares Dl_info (along with dladdr) when
_GNU_SOURCE is defined. C++ compilers define it by default on Linux, but
C compilers don't, so the dlfcn-host regression test, which is compiled
as C, failed to compile on Linux.
Define _GNU_SOURCE in the test, and document the requirement in
dlfcn-host.h for other C clients.
Assisted-by: Claude
LowerTypeTests: Only invalidate analyses of modified functions in SimplifyTypeTests (#244852)
SimplifyTypeTests tried to preserve the CFG analyses, but did not
preserve the function analysis manager proxy, so all function analyses
were invalidated.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[LFI][AArch64] Use BTI JC for function landing pads due to tail calls (#244058)
LFI rewrites every indirect branch through x28, including tail calls
that would normally use x16/x17, so we get a fault if a tail call lands
on a `bti c`. This patch makes codegen emit `bti jc` for indirect call
targets under LFI, even before `paciasp`/`pacibsp`, and makes the MC
rewriter turn `bti c` into `bti jc` so hand-written assembly is covered
too.
Assisted by: Claude Opus 5.5
[CodeGen] Disable passes requiring NoVRegs on virtual-register targets (#245089)
NVPTX, SPIR-V, and WebAssembly keep virtual registers until emission.
Each disables the same post-RA passes, which require NoVRegs, in both
TargetPassConfig and its CodeGenPassBuilder, and overrides hooks so no
register allocator is added. Key both on
TargetMachine::usesPhysRegsForValues() instead: TargetPassConfig and
CodeGenPassBuilder disable the passes in one list, and addFastRegAlloc
and addOptimizedRegAlloc skip allocation. NVPTX now returns false from
usesPhysRegsForValues().
addRegAssignAndRewriteFast and addRegAssignAndRewriteOptimized returned
bool, or Expected<bool>, only to let these targets report that nothing
was added. They now return void, or Error.
LLM-aided
[mlir][AMDGPU] Fix canonicalize crash on trailing memory_counter_wait (#245028)
FuseMemoryCounterWaitOp called dyn_cast on the possibly-null next node,
which asserts when the op is last in its block. Use dyn_cast_or_null.
Fixes #239940.
[Clang][CUDA] Guard curand_mtgp32_kernel.h include with has_include (#244945)
`__clang_cuda_runtime_wrapper.h` forcefully includes
`curand_mtgp32_kernel.h`. On a minimal CUDA setup (`cuda -nvcc` and
`cuda-cudart-dev` installed), compiling any CUDA code using `clang++`
fails with `fatal error: 'curand_mtgp32_kernel.h' file not found`, even
when the code does not use cuRAND.
The fix guards `#include "curand_mtgp32_kernel.h"` and its surrounding
`dim3`/`uint3`, `push_macro`/`define`/`pop_macro` "hack" in
`clang/lib/Headers/__clang_cuda_runtime_wrapper.h` with `#if
__has_include("curand_mtgp32_kernel.h")`.
Removed the stub
`clang/test/Headers/Inputs/include/curand_mtgp32_kernel.h`, as keeping
the stub in the shared `Inputs/include/` mock tree made the
missing-header case really hard to test, as they would vacuously pass
even on an unpatched wrapper. It also makes existing tests like
`gpu_disabled_math.cpp` and `cuda_with_openmp.cu` exercise the
[5 lines not shown]
[RISCV] Fix scalar minimum/maximum cost without Zfa (#239996)
Cost them as fmin/fmax plus a NaN compare and select instead of the
generic libcall cost, or just fmin/fmax with nnan. Also add nnan tests.
[flang] Reject INTENT on non-pointer dummy procedure (#240042)
### Summary
Fix missing semantic diagnostic for INTENT on non-pointer dummy
procedures. The existing check only covered `ProcEntityDetails`, missing
procedures represented by `SubprogramDetails`. Moved the validation to
the shared `CheckHelper::Check()` path to ensure consistent enforcement
across both representations, with regression tests added.
Fixes #229220.
---------
Co-authored-by: Jay Satish Kumar Patel <kumarpat at pe31.hpc.amslabs.hpecorp.net>
Co-authored-by: Copilot <223556219+Copilot at users.noreply.github.com>
[MC] Fold CFI advance_loc when applicable. NFC (#245130)
In many cases both labels are in the fixed part of a fragment without
linker relaxation. We should fold the advance_loc to save space and
time.
https://reviews.llvm.org/D150004 removed a fast path because it folded
deltas across linker-relaxable instructions. `absoluteSymbolDiff` now
rejects such fragments.
[libc][FPUtil] Make hardware helpers usable in constant expressions (#242283)
## Summary
Part of #195623 (split 1/2). Makes the `FPUtil` hardware helpers usable
in constant expressions, which is the foundation the shared math
functions build on in #242285.
## What this PR does
- Guards the hardware/intrinsic paths in `FEnvImpl`, `sqrt`, `FMA`,
`nearest_integer`, and `multiply_add` behind `is_constant_evaluated()`,
so they fall through to the generic implementation during constant
evaluation while still using the hardware path at runtime.
- Applies this across all supported architectures: aarch64, arm,
hexagon, riscv, and x86_64.
## Compatibility
[10 lines not shown]
[mlir][Affine] Fix crash in loopUnrollUpToFactor on zero-trip loops (#245019)
When the constant trip count was lower than the unroll factor,
loopUnrollUpToFactor clamped the factor to the trip count. For a
zero-trip loop (e.g. `affine.for %i = 0 to 0`) this called
loopUnrollByFactor with factor 0 and tripped its "unroll factor should
be positive" assertion. Return early for zero-trip loops as
loopUnrollFull does, since there is nothing to unroll. Fixes #220458.
Assisted-by: MiMo-V2.6-Pro
[MC] Change section group name from Twine to StringRef. NFC (#245125)
str() conversions are expensive. All but one caller
(MCObjectFileInfo::getPseudoProbeDescSection) pass a StringRef. Take a
StringRef.
Coroutines: Only invalidate analyses of lowered functions in CoroCleanup
CoroCleanupPass already invalidates the analyses of the functions it
lowers, but then reported no preserved analyses, which clears every
cached function.
Also stop preserving CFG analyses for lowered functions, since noop
coroutine elision can change the CFG.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[MC] Hash section names once in recordELFMergeableSectionInfo. NFC (#245122)
Key both ELFSeenGenericMergeableSections and ELFEntrySizeMap by
CachedHashStringRef so that hash lookups don't need to recompute the
section name hash. ELFSeenGenericmergeableSections contains most
sections and the long C++ mangled names are expensive.
RuntimeLibcalls: Add SME attributes to the AArch64 SME support routines
SMEAttrs currently assumes these attributes based on the function
name. Add them to the function definition so this code can be cleaned
up in the future.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[orc-rt] Add DlfcnLoaderAdapter. (#245120)
DlfcnLoaderAdapter simplifies exposing an ORC runtime loader through the
dlfcn.h APIs. Subclasses implement dlopen, dlclose, dlsym, and dladdr in
terms of their underlying loader, reporting failures with Error and
Expected as usual in the ORC runtime. The adapter takes care of
translating those results into dlfcn.h's error-reporting scheme: each
failure returns the operation's POSIX failure value, and its message is
made available to the calling thread through dlerror. Failures are also
logged, under a new LoaderAPIs logging category.
JIT'd code reaches an adapter through C entry points
(orc_rt_DlfcnLoaderAdapter_*) and an instance symbol,
orc_rt_DlfcnLoaderAdapter_Instance, which the adapter adds to a symbol
table supplied by its creator. The creator publishes that table to the
session once the whole loader system has been constructed.
Supporting changes:
- orc-rt-c/bedrock/sys/posix/dlfcn-types.h provides orc_rt_Dl_info and
[6 lines not shown]
LowerTypeTests: Only invalidate analyses of modified functions in SimplifyTypeTests
SimplifyTypeTests tried to preserve the CFG analyses, but did not
preserve the function analysis manager proxy, so all function analyses
were invalidated.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
RuntimeLibcalls: Add attributes to __arm_sc_memcpy, memmove and memset
The streaming-compatible variants behave like memcpy, memmove and
memset. Omit captures(none) since these can be used to implement volatile
memory intrinsics.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>