[CodeGen] Honor disabled and reserved CSRs in `getCalleeSavedRegs` (#241593)
Previously, `getCalleeSavedRegs` simply returned the unfiltered TRI CSRs
on its first invocation, even when it had already populated
`UpdatedCSRs`. And calling `disableCalleeSavedRegister` prior to
`getCalleeSavedRegs` initialized `UpdatedCSRs` without filtering out
user-reserved registers.
Additionally, both the prolog/epilog inserter for zeroing call used
registers, and the register usage collector queried
`TRI.getCalleeSavedRegs`, ignoring anything disabled with
`disableCalleeSavedRegister`.
All this led to miscompiles:
https://cpp.compiler-explorer.com/z/rKdcnq7oP
Fixed by correctly returning `UpdatedCSRs` from MRI's
`getCalleeSavedRegs`, filtering user-reserved registers when populating
it, and changing the places to call it rather than TRI.
Assisted-by: Antigravity with Gemini
[clang][Sparc] Define _SOFT_FLOAT instead of SOFT_FLOAT (#245137)
With -msoft-float, Clang defined SOFT_FLOAT to 1. GCC defines
_SOFT_FLOAT, and SOFT_FLOAT is not in the reserved namespace. Do what
GCC does.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[CIR] Add a split mode to cir-offload-merge
Write each module of an offload container to its own file, named after
the driver's offload files (<stem>-<kind>-<triple>.cir). Combine keeps
the original module name in cir.offload.source_name so split can give
back the modules as they were before combine.
[LoopUnroll] Avoid revisiting shared SCEVs in uniformity checks (#244318)
Checking whether a backedge count is uniform can take exponential time
when its SCEV contains shared subexpressions. Use SCEVExprContains to
visit each node once.
LoopUnroll only checks backedge count uniformity for targets with branch
divergence. The regression test uses AMDGPU to exercise that check.
Assisted-by: OpenAI Codex
[Sparc][MC] Reject out-of-range %rN register names (#245110)
matchRegisterName only parsed the first two digits after "%r", so
"%r100" was accepted as %r10 (%o2), "%r145" as %r14 (%sp) and "%r310"
as %r31 (%i7). Parse the whole number instead.
GNU as rejects these names too.
Co-authored-by: Claude Opus 5.5 <noreply at anthropic.com>
[mlir][nvgpu] Do not convert transfers masked by vector.mask to async copies (#238721)
`createAsyncGroups` checked the mask operand of a
`vector.transfer_write` but not an enclosing `vector.mask`. A
region-masked write was replaced in place, which dropped the mask and
left non-maskable ops inside the `vector.mask` region, failing
verification.
Reject transfers masked by `vector.mask`.
Found while auditing the `in_bounds` readers for #227821.
Part of #239511.
[orc-rt][ORC] Let controllers create SimpleNativeMemoryMaps (#245113)
Executors previously had to create a SimpleNativeMemoryMap up front and
publish it under an instance symbol. This commit adds a create
entrypoint, orc_rt_ci_sps_SimpleNativeMemoryMap_create, that constructs
a new instance, adds it to the calling Session as a Service, and returns
its address. Executors still decide whether SimpleNativeMemoryMap is
available, but controllers now decide whether to create instances, and
how many.
orc-rt changes:
* SimpleNativeMemoryMap's Create methods are replaced with a public
constructor, and its header no longer depends on the SPS controller
interface.
* sps::ci::addSimpleNativeMemoryMap adds the create entrypoint along
with the memory operations. It is still called from sps::ci::addAll.
* ogre no longer creates an instance, since sps::ci::addAll now
publishes the create entrypoint.
[14 lines not shown]
[mlir][acc] Translate the acc.offload_entry attribute to an offloading entry (#242809)
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
[clang-repl] Use an in-memory main file and createTarget in CreateCI (#243830)
This PR simplifies how clang-repl sets up its compiler instance.
clang-repl needs an empty starting file, which was previously provided
through a heap-allocated buffer that leaked if nothing used it, so the
unit tests had to free it by hand. That file is now an empty in-memory
input that needs no cleanup, so the manual cleanup in the tests is
removed.
It also replaces the hand-written target setup with clang's existing
`createTarget()` helper.
Assisted by Claude Opus 5.5
[mlir][acc] Translate #acc.offload_packager to LLVM IR (#242808)
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] 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]